game.h

main 598 lines · 23.7 KB Raw
Alex Alex Commit Server upload 18/10/2026 23:38
1/**
2 * The Forgotten Server - a free and open-source MMORPG server emulator
3 * Copyright (C) 2019 Mark Samman <mark.samman@gmail.com>
4 *
5 * This program is free software; you can redistribute it and/or modify
6 * it under the terms of the GNU General Public License as published by
7 * the Free Software Foundation; either version 2 of the License, or
8 * (at your option) any later version.
9 *
10 * This program is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13 * GNU General Public License for more details.
14 *
15 * You should have received a copy of the GNU General Public License along
16 * with this program; if not, write to the Free Software Foundation, Inc.,
17 * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
18 */
19
20#ifndef FS_GAME_H_3EC96D67DD024E6093B3BAC29B7A6D7F
21#define FS_GAME_H_3EC96D67DD024E6093B3BAC29B7A6D7F
22
23#include "account.h"
24#include "combat.h"
25#include "groups.h"
26#include "map.h"
27#include "position.h"
28#include "item.h"
29#include "container.h"
30#include "player.h"
31#include "runeeffects.h"
32#include "raids.h"
33#include "npc.h"
34#include "wildcardtree.h"
35#include "quests.h"
36#include "shaders.h"
37
38class ServiceManager;
39class Creature;
40class Monster;
41class Npc;
42class CombatInfo;
43
44enum stackPosType_t {
45 STACKPOS_MOVE,
46 STACKPOS_LOOK,
47 STACKPOS_TOPDOWN_ITEM,
48 STACKPOS_USEITEM,
49 STACKPOS_USETARGET,
50};
51
52enum WorldType_t {
53 WORLD_TYPE_NO_PVP = 1,
54 WORLD_TYPE_PVP = 2,
55 WORLD_TYPE_PVP_ENFORCED = 3,
56};
57
58enum GameState_t {
59 GAME_STATE_STARTUP,
60 GAME_STATE_INIT,
61 GAME_STATE_NORMAL,
62 GAME_STATE_CLOSED,
63 GAME_STATE_SHUTDOWN,
64 GAME_STATE_CLOSING,
65 GAME_STATE_MAINTAIN,
66};
67
68enum LightState_t {
69 LIGHT_STATE_DAY,
70 LIGHT_STATE_NIGHT,
71 LIGHT_STATE_SUNSET,
72 LIGHT_STATE_SUNRISE,
73};
74
75static constexpr int32_t EVENT_LIGHTINTERVAL = 10000;
76static constexpr int32_t EVENT_DECAYINTERVAL = 250;
77static constexpr int32_t EVENT_DECAY_BUCKETS = 4;
78
79/**
80 * Main Game class.
81 * This class is responsible to control everything that happens
82 */
83
84class Game
85{
86 public:
87 Game();
88 ~Game();
89
90 // non-copyable
91 Game(const Game&) = delete;
92 Game& operator=(const Game&) = delete;
93
94 void start(ServiceManager* manager);
95
96 void forceAddCondition(uint32_t creatureId, Condition* condition);
97 void forceRemoveCondition(uint32_t creatureId, ConditionType_t type);
98
99 bool loadMainMap(const std::string& filename);
100 void loadMap(const std::string& path);
101
102 /**
103 * Get the map size - info purpose only
104 * \param width width of the map
105 * \param height height of the map
106 */
107 void getMapDimensions(uint32_t& width, uint32_t& height) const {
108 width = map.width;
109 height = map.height;
110 }
111
112 void setWorldType(WorldType_t type);
113 WorldType_t getWorldType() const {
114 return worldType;
115 }
116
117 Cylinder* internalGetCylinder(Player* player, const Position& pos) const;
118 Thing* internalGetThing(Player* player, const Position& pos, int32_t index,
119 uint32_t spriteId, stackPosType_t type) const;
120 static void internalGetPosition(Item* item, Position& pos, uint8_t& stackpos);
121
122 static std::string getTradeErrorDescription(ReturnValue ret, Item* item);
123
124 /**
125 * Returns a creature based on the unique creature identifier
126 * \param id is the unique creature id to get a creature pointer to
127 * \returns A Creature pointer to the creature
128 */
129 Creature* getCreatureByID(uint32_t id);
130
131 /**
132 * Returns a monster based on the unique creature identifier
133 * \param id is the unique monster id to get a monster pointer to
134 * \returns A Monster pointer to the monster
135 */
136 Monster* getMonsterByID(uint32_t id);
137
138 /**
139 * Returns a npc based on the unique creature identifier
140 * \param id is the unique npc id to get a npc pointer to
141 * \returns A NPC pointer to the npc
142 */
143 Npc* getNpcByID(uint32_t id);
144
145 /**
146 * Returns a player based on the unique creature identifier
147 * \param id is the unique player id to get a player pointer to
148 * \returns A Pointer to the player
149 */
150 Player* getPlayerByID(uint32_t id);
151
152 /**
153 * Returns a creature based on a string name identifier
154 * \param s is the name identifier
155 * \returns A Pointer to the creature
156 */
157 Creature* getCreatureByName(const std::string& s);
158
159 /**
160 * Returns a npc based on a string name identifier
161 * \param s is the name identifier
162 * \returns A Pointer to the npc
163 */
164 Npc* getNpcByName(const std::string& s);
165
166 /**
167 * Returns a player based on a string name identifier
168 * \param s is the name identifier
169 * \returns A Pointer to the player
170 */
171 Player* getPlayerByName(const std::string& s);
172
173 /**
174 * Returns a player based on guid
175 * \returns A Pointer to the player
176 */
177 Player* getPlayerByGUID(const uint32_t& guid);
178
179 /**
180 * Returns a player based on a string name identifier, with support for the "~" wildcard.
181 * \param s is the name identifier, with or without wildcard
182 * \param player will point to the found player (if any)
183 * \return "RETURNVALUE_PLAYERWITHTHISNAMEISNOTONLINE" or "RETURNVALUE_NAMEISTOOAMBIGIOUS"
184 */
185 ReturnValue getPlayerByNameWildcard(const std::string& s, Player*& player);
186
187 /**
188 * Returns a player based on an account number identifier
189 * \param acc is the account identifier
190 * \returns A Pointer to the player
191 */
192 Player* getPlayerByAccount(uint32_t acc);
193
194 /* Place Creature on the map without sending out events to the surrounding.
195 * \param creature Creature to place on the map
196 * \param pos The position to place the creature
197 * \param extendedPos If true, the creature will in first-hand be placed 2 tiles away
198 * \param forced If true, placing the creature will not fail because of obstacles (creatures/items)
199 */
200 bool internalPlaceCreature(Creature* creature, const Position& pos, bool extendedPos = false, bool forced = false);
201
202 /**
203 * Place Creature on the map.
204 * \param creature Creature to place on the map
205 * \param pos The position to place the creature
206 * \param extendedPos If true, the creature will in first-hand be placed 2 tiles away
207 * \param force If true, placing the creature will not fail because of obstacles (creatures/items)
208 */
209 bool placeCreature(Creature* creature, const Position& pos, bool extendedPos = false, bool forced = false);
210
211 /**
212 * Remove Creature from the map.
213 * Removes the Creature the map
214 * \param c Creature to remove
215 */
216 bool removeCreature(Creature* creature, bool isLogout = true);
217
218 void addCreatureCheck(Creature* creature);
219 static void removeCreatureCheck(Creature* creature);
220
221 size_t getPlayersOnline() const {
222 return players.size();
223 }
224 size_t getMonstersOnline() const {
225 return monsters.size();
226 }
227 size_t getNpcsOnline() const {
228 return npcs.size();
229 }
230 uint32_t getPlayersRecord() const {
231 return playersRecord;
232 }
233
234 LightInfo getWorldLightInfo() const;
235
236 ReturnValue internalMoveCreature(Creature* creature, Direction direction, uint32_t flags = 0);
237 ReturnValue internalMoveCreature(Creature& creature, Tile& toTile, uint32_t flags = 0);
238
239 ReturnValue internalMoveItem(Cylinder* fromCylinder, Cylinder* toCylinder, int32_t index,
240 Item* item, uint32_t count, Item** _moveItem, uint32_t flags = 0, Creature* actor = nullptr, Item* tradeItem = nullptr, const Position* fromPos = nullptr, const Position* toPos = nullptr);
241
242 ReturnValue internalAddItem(Cylinder* toCylinder, Item* item, int32_t index = INDEX_WHEREEVER,
243 uint32_t flags = 0, bool test = false);
244 ReturnValue internalAddItem(Cylinder* toCylinder, Item* item, int32_t index,
245 uint32_t flags, bool test, uint32_t& remainderCount);
246 ReturnValue internalRemoveItem(Item* item, int32_t count = -1, bool test = false, uint32_t flags = 0);
247
248 ReturnValue internalPlayerAddItem(Player* player, Item* item, bool dropOnMap = true, slots_t slot = CONST_SLOT_WHEREEVER);
249
250 /**
251 * Find an item of a certain type
252 * \param cylinder to search the item
253 * \param itemId is the item to remove
254 * \param subType is the extra type an item can have such as charges/fluidtype, default is -1
255 * meaning it's not used
256 * \param depthSearch if true it will check child containers aswell
257 * \returns A pointer to the item to an item and nullptr if not found
258 */
259 Item* findItemOfType(Cylinder* cylinder, uint16_t itemId,
260 bool depthSearch = true, int32_t subType = -1) const;
261
262 /**
263 * Remove/Add item(s) with a monetary value
264 * \param cylinder to remove the money from
265 * \param money is the amount to remove
266 * \param flags optional flags to modifiy the default behaviour
267 * \returns true if the removal was successful
268 */
269 bool removeMoney(Cylinder* cylinder, uint64_t money, uint32_t flags = 0);
270
271 /**
272 * Add item(s) with monetary value
273 * \param cylinder which will receive money
274 * \param money the amount to give
275 * \param flags optional flags to modify default behavior
276 */
277 void addMoney(Cylinder* cylinder, uint64_t money, uint32_t flags = 0);
278
279 /**
280 * Transform one item to another type/count
281 * \param item is the item to transform
282 * \param newId is the new itemid
283 * \param newCount is the new count value, use default value (-1) to not change it
284 * \returns true if the tranformation was successful
285 */
286 Item* transformItem(Item* item, uint16_t newId, int32_t newCount = -1);
287
288 /**
289 * Teleports an object to another position
290 * \param thing is the object to teleport
291 * \param newPos is the new position
292 * \param pushMove force teleport if false
293 * \param flags optional flags to modify default behavior
294 * \returns true if the teleportation was successful
295 */
296 ReturnValue internalTeleport(Thing* thing, const Position& newPos, bool pushMove = true, uint32_t flags = 0);
297
298 /**
299 * Turn a creature to a different direction.
300 * \param creature Creature to change the direction
301 * \param dir Direction to turn to
302 */
303 bool internalCreatureTurn(Creature* creature, Direction dir);
304
305 /**
306 * Creature wants to say something.
307 * \param creature Creature pointer
308 * \param type Type of message
309 * \param text The text to say
310 */
311 bool internalCreatureSay(Creature* creature, SpeakClasses type, const std::string& text,
312 bool ghostMode, SpectatorVec* spectatorsPtr = nullptr, const Position* pos = nullptr);
313
314 void loadPlayersRecord();
315 void checkPlayersRecord();
316
317 void sendGuildMotd(uint32_t playerId);
318 void kickPlayer(uint32_t playerId, bool displayEffect);
319 void playerReportBug(uint32_t playerId, const std::string& message, const Position& position, uint8_t category);
320 void playerDebugAssert(uint32_t playerId, const std::string& assertLine, const std::string& date, const std::string& description, const std::string& comment);
321 void playerAnswerModalWindow(uint32_t playerId, uint32_t modalWindowId, uint8_t button, uint8_t choice);
322 void playerReportRuleViolation(uint32_t playerId, const std::string& targetName, uint8_t reportType, uint8_t reportReason, const std::string& comment, const std::string& translation);
323
324 bool internalStartTrade(Player* player, Player* tradePartner, Item* tradeItem);
325 void internalCloseTrade(Player* player);
326 bool playerBroadcastMessage(Player* player, const std::string& text) const;
327 void broadcastMessage(const std::string& text, MessageClasses type) const;
328
329 //Implementation of player invoked events
330 void playerMoveThing(uint32_t playerId, const Position& fromPos, uint16_t spriteId, uint8_t fromStackPos,
331 const Position& toPos, uint8_t count);
332 void playerMoveCreatureByID(uint32_t playerId, uint32_t movingCreatureId, const Position& movingCreatureOrigPos, const Position& toPos);
333 void playerMoveCreature(Player* player, Creature* movingCreature, const Position& movingCreatureOrigPos, Tile* toTile);
334 void playerMoveItemByPlayerID(uint32_t playerId, const Position& fromPos, uint16_t spriteId, uint8_t fromStackPos, const Position& toPos, uint8_t count);
335 void playerMoveItem(Player* player, const Position& fromPos,
336 uint16_t spriteId, uint8_t fromStackPos, const Position& toPos, uint8_t count, Item* item, Cylinder* toCylinder);
337 void playerEquipItem(uint32_t playerId, uint16_t spriteId);
338 void playerMove(uint32_t playerId, Direction direction);
339 void playerCreatePrivateChannel(uint32_t playerId);
340 void playerChannelInvite(uint32_t playerId, const std::string& name);
341 void playerChannelExclude(uint32_t playerId, const std::string& name);
342 void playerRequestChannels(uint32_t playerId);
343 void playerOpenChannel(uint32_t playerId, uint16_t channelId);
344 void playerCloseChannel(uint32_t playerId, uint16_t channelId);
345 void playerOpenPrivateChannel(uint32_t playerId, std::string& receiver);
346 void playerCloseNpcChannel(uint32_t playerId);
347 void playerReceivePing(uint32_t playerId);
348 void playerReceivePingBack(uint32_t playerId);
349 void playerReceiveNewPing(uint32_t playerId, uint16_t ping, uint16_t fps);
350 void playerAutoWalk(uint32_t playerId, const std::list<Direction>& listDir);
351 void playerNewWalk(uint32_t playerId, Position pos, uint8_t flags, std::list<Direction> listDir);
352 void playerStopAutoWalk(uint32_t playerId);
353 void playerUseItemEx(uint32_t playerId, const Position& fromPos, uint8_t fromStackPos,
354 uint16_t fromSpriteId, const Position& toPos, uint8_t toStackPos, uint16_t toSpriteId);
355 void playerUseItem(uint32_t playerId, const Position& pos, uint8_t stackPos, uint8_t index, uint16_t spriteId);
356 void playerUseWithCreature(uint32_t playerId, const Position& fromPos, uint8_t fromStackPos, uint32_t creatureId, uint16_t spriteId);
357 void playerCloseContainer(uint32_t playerId, uint8_t cid);
358 void playerMoveUpContainer(uint32_t playerId, uint8_t cid);
359 void playerUpdateContainer(uint32_t playerId, uint8_t cid);
360 void playerRotateItem(uint32_t playerId, const Position& pos, uint8_t stackPos, const uint16_t spriteId);
361 void playerWriteItem(uint32_t playerId, uint32_t windowTextId, const std::string& text);
362 void playerBrowseField(uint32_t playerId, const Position& pos);
363 void playerSeekInContainer(uint32_t playerId, uint8_t containerId, uint16_t index);
364 void playerUpdateHouseWindow(uint32_t playerId, uint8_t listId, uint32_t windowTextId, const std::string& text);
365 void playerWrapItem(uint32_t playerId, const Position& position, uint8_t stackPos, const uint16_t spriteId);
366 void playerRequestTrade(uint32_t playerId, const Position& pos, uint8_t stackPos,
367 uint32_t tradePlayerId, uint16_t spriteId);
368 void playerAcceptTrade(uint32_t playerId);
369 void playerLookInTrade(uint32_t playerId, bool lookAtCounterOffer, uint8_t index);
370 void playerPurchaseItem(uint32_t playerId, uint16_t spriteId, uint8_t count, uint8_t amount,
371 bool ignoreCap = false, bool inBackpacks = false);
372 void playerSellItem(uint32_t playerId, uint16_t spriteId, uint8_t count,
373 uint8_t amount, bool ignoreEquipped = false);
374 void playerCloseShop(uint32_t playerId);
375 void playerLookInShop(uint32_t playerId, uint16_t spriteId, uint8_t count);
376 void playerCloseTrade(uint32_t playerId);
377 void playerSetAttackedCreature(uint32_t playerId, uint32_t creatureId);
378 void playerFollowCreature(uint32_t playerId, uint32_t creatureId);
379 void playerCancelAttackAndFollow(uint32_t playerId);
380 void playerSetFightModes(uint32_t playerId, fightMode_t fightMode, bool chaseMode, bool secureMode);
381 void playerLookAt(uint32_t playerId, const Position& pos, uint8_t stackPos);
382 void playerLookInBattleList(uint32_t playerId, uint32_t creatureId);
383 void playerRequestAddVip(uint32_t playerId, const std::string& name);
384 void playerRequestRemoveVip(uint32_t playerId, uint32_t guid);
385 void playerRequestEditVip(uint32_t playerId, uint32_t guid, const std::string& description, uint32_t icon, bool notify);
386 void playerTurn(uint32_t playerId, Direction dir);
387 void playerRequestOutfit(uint32_t playerId);
388 void playerShowQuestLog(uint32_t playerId);
389 void playerShowQuestLine(uint32_t playerId, uint16_t questId);
390 void playerSay(uint32_t playerId, uint16_t channelId, SpeakClasses type,
391 const std::string& receiver, const std::string& text);
392 void playerChangeOutfit(uint32_t playerId, Outfit_t outfit);
393 void playerInviteToParty(uint32_t playerId, uint32_t invitedId);
394 void playerJoinParty(uint32_t playerId, uint32_t leaderId);
395 void playerRevokePartyInvitation(uint32_t playerId, uint32_t invitedId);
396 void playerPassPartyLeadership(uint32_t playerId, uint32_t newLeaderId);
397 void playerLeaveParty(uint32_t playerId);
398 void playerEnableSharedPartyExperience(uint32_t playerId, bool sharedExpActive);
399 void playerToggleOutfitExtension(uint32_t playerId, int mount, int wings, int aura, int shader, int runeeffect);
400 void playerLeaveMarket(uint32_t playerId);
401 void playerBrowseMarket(uint32_t playerId, uint16_t spriteId);
402 void playerBrowseMarketOwnOffers(uint32_t playerId);
403 void playerBrowseMarketOwnHistory(uint32_t playerId);
404 void playerCreateMarketOffer(uint32_t playerId, uint8_t type, uint16_t spriteId, uint16_t amount, uint32_t price, bool anonymous);
405 void playerCancelMarketOffer(uint32_t playerId, uint32_t timestamp, uint16_t counter);
406 void playerAcceptMarketOffer(uint32_t playerId, uint32_t timestamp, uint16_t counter, uint16_t amount);
407
408 void parsePlayerExtendedOpcode(uint32_t playerId, uint8_t opcode, const std::string& buffer);
409
410 std::forward_list<Item*> getMarketItemList(uint16_t wareId, uint16_t sufficientCount, DepotChest* depotChest, Inbox* inbox);
411
412 static void updatePremium(Account& account);
413
414 void cleanup();
415 void shutdown();
416 void ReleaseCreature(Creature* creature);
417 void ReleaseItem(Item* item);
418
419 bool canThrowObjectTo(const Position& fromPos, const Position& toPos, bool checkLineOfSight = true,
420 int32_t rangex = Map::maxClientViewportX, int32_t rangey = Map::maxClientViewportY) const;
421 bool isSightClear(const Position& fromPos, const Position& toPos, bool floorCheck) const;
422
423 void changeSpeed(Creature* creature, int32_t varSpeedDelta);
424 void internalCreatureChangeOutfit(Creature* creature, const Outfit_t& outfit);
425 void internalCreatureChangeVisible(Creature* creature, bool visible);
426 void changeLight(const Creature* creature);
427 void updateCreatureSkull(const Creature* creature);
428 void updatePlayerShield(Player* player);
429 void updatePlayerHelpers(const Player& player);
430 void updateCreatureType(Creature* creature);
431 void updateCreatureWalkthrough(const Creature* creature);
432
433 GameState_t getGameState() const;
434 void setGameState(GameState_t newState);
435 void saveGameState();
436
437 //Events
438 void checkCreatureWalk(uint32_t creatureId);
439 void updateCreatureWalk(uint32_t creatureId);
440 void checkCreatureAttack(uint32_t creatureId);
441 void checkCreatures(size_t index);
442 void checkLight();
443
444 bool combatBlockHit(CombatDamage& damage, Creature* attacker, Creature* target, bool checkDefense, bool checkArmor, bool field);
445
446 void combatGetTypeInfo(CombatType_t combatType, Creature* target, TextColor_t& color, uint8_t& effect);
447
448 bool combatChangeHealth(Creature* attacker, Creature* target, CombatDamage& damage);
449 bool combatChangeMana(Creature* attacker, Creature* target, CombatDamage& damage);
450
451 //animation help functions
452 void addCreatureHealth(const Creature* target);
453 static void addCreatureHealth(const SpectatorVec& spectators, const Creature* target);
454 void addMagicEffect(const Position& pos, uint16_t effect); // Cambiado de uint8_t a uint16_t
455 static void addMagicEffect(const SpectatorVec& spectators, const Position& pos, uint16_t effect); // Cambiado de uint8_t a uint16_t
456 void addDistanceEffect(const Position& fromPos, const Position& toPos, uint8_t effect);
457 static void addDistanceEffect(const SpectatorVec& spectators, const Position& fromPos, const Position& toPos, uint8_t effect);
458
459 void startDecay(Item* item);
460 int32_t getLightHour() const {
461 return lightHour;
462 }
463
464 bool loadExperienceStages();
465 uint64_t getExperienceStage(uint32_t level);
466
467 void loadMotdNum();
468 void saveMotdNum() const;
469 const std::string& getMotdHash() const { return motdHash; }
470 uint32_t getMotdNum() const { return motdNum; }
471 void incrementMotdNum() { motdNum++; }
472
473 void sendOfflineTrainingDialog(Player* player);
474
475 const std::unordered_map<uint32_t, Player*>& getPlayers() const { return players; }
476 const std::map<uint32_t, Npc*>& getNpcs() const { return npcs; }
477
478 void addPlayer(Player* player);
479 void removePlayer(Player* player);
480
481 void addNpc(Npc* npc);
482 void removeNpc(Npc* npc);
483
484 void addMonster(Monster* monster);
485 void removeMonster(Monster* monster);
486
487 Guild* getGuild(uint32_t id) const;
488 void addGuild(Guild* guild);
489 void removeGuild(uint32_t guildId);
490 void decreaseBrowseFieldRef(const Position& pos);
491
492 std::unordered_map<Tile*, Container*> browseFields;
493
494 void internalRemoveItems(std::vector<Item*> itemList, uint32_t amount, bool stackable);
495
496 BedItem* getBedBySleeper(uint32_t guid) const;
497 void setBedSleeper(BedItem* bed, uint32_t guid);
498 void removeBedSleeper(uint32_t guid);
499
500 Item* getUniqueItem(uint16_t uniqueId);
501 bool addUniqueItem(uint16_t uniqueId, Item* item);
502 void removeUniqueItem(uint16_t uniqueId);
503
504 bool reload(ReloadTypes_t reloadType);
505
506 Auras auras;
507 Groups groups;
508 Map map;
509 Mounts mounts;
510 Raids raids;
511 RuneEffects runeEffects;
512 Quests quests;
513 Wings wings;
514 Shaders shaders;
515
516 std::forward_list<Item*> toDecayItems;
517
518 std::unordered_set<Tile*> getTilesToClean() const {
519 return tilesToClean;
520 }
521 void addTileToClean(Tile* tile) {
522 tilesToClean.emplace(tile);
523 }
524 void removeTileToClean(Tile* tile) {
525 tilesToClean.erase(tile);
526 }
527 void clearTilesToClean() {
528 tilesToClean.clear();
529 }
530
531 private:
532 bool playerSaySpell(Player* player, SpeakClasses type, const std::string& text);
533 void playerWhisper(Player* player, const std::string& text);
534 bool playerYell(Player* player, const std::string& text);
535 bool playerSpeakTo(Player* player, SpeakClasses type, const std::string& receiver, const std::string& text);
536 void playerSpeakToNpc(Player* player, const std::string& text);
537
538 void checkDecay();
539 void internalDecayItem(Item* item);
540
541 std::unordered_map<uint32_t, Player*> players;
542 std::unordered_map<std::string, Player*> mappedPlayerNames;
543 std::unordered_map<uint32_t, Player*> mappedPlayerGuids;
544 std::unordered_map<uint32_t, Guild*> guilds;
545 std::unordered_map<uint16_t, Item*> uniqueItems;
546 std::map<uint32_t, uint32_t> stages;
547
548 std::list<Item*> decayItems[EVENT_DECAY_BUCKETS];
549 std::list<Creature*> checkCreatureLists[EVENT_CREATURECOUNT];
550
551 std::vector<Creature*> ToReleaseCreatures;
552 std::vector<Item*> ToReleaseItems;
553
554 size_t lastBucket = 0;
555
556 WildcardTreeNode wildcardTree { false };
557
558 std::map<uint32_t, Npc*> npcs;
559 std::map<uint32_t, Monster*> monsters;
560
561 //list of items that are in trading state, mapped to the player
562 std::map<Item*, uint32_t> tradeItems;
563
564 std::map<uint32_t, BedItem*> bedSleepersMap;
565
566 std::unordered_set<Tile*> tilesToClean;
567
568 ModalWindow offlineTrainingWindow { std::numeric_limits<uint32_t>::max(), "Choose a Skill", "Please choose a skill:" };
569
570 static constexpr int32_t LIGHT_LEVEL_DAY = 250;
571 static constexpr int32_t LIGHT_LEVEL_NIGHT = 40;
572 static constexpr int32_t SUNSET = 1305;
573 static constexpr int32_t SUNRISE = 430;
574
575 GameState_t gameState = GAME_STATE_NORMAL;
576 WorldType_t worldType = WORLD_TYPE_PVP;
577
578 LightState_t lightState = LIGHT_STATE_DAY;
579 uint8_t lightLevel = LIGHT_LEVEL_DAY;
580 int32_t lightHour = SUNRISE + (SUNSET - SUNRISE) / 2;
581 // (1440 minutes/day)/(3600 seconds/day)*10 seconds event interval
582 int32_t lightHourDelta = 1400 * 10 / 3600;
583
584 ServiceManager* serviceManager = nullptr;
585
586 void updatePlayersRecord() const;
587 uint32_t playersRecord = 0;
588
589 std::string motdHash;
590 uint32_t motdNum = 0;
591
592 uint32_t lastStageLevel = 0;
593 bool stagesEnabled = false;
594 bool useLastStageLevel = false;
595};
596
597#endif
598
Top