|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <fstream>
|
|
|
|
|
#include <memory>
|
|
|
|
|
#include <sstream>
|
|
|
|
|
|
|
|
|
|
#include "Backend/DAPIBackendCore/DAPIProtoClient.h"
|
|
|
|
|
#include "GameData.h"
|
|
|
|
|
|
|
|
|
|
#include "control.h"
|
|
|
|
|
#include "cursor.h"
|
|
|
|
|
#include "diablo.h"
|
|
|
|
|
#include "engine/random.hpp"
|
|
|
|
|
#include "gamemenu.h"
|
|
|
|
|
#include "gmenu.h"
|
|
|
|
|
#include "inv.h"
|
|
|
|
|
#include "levels/gendung.h"
|
|
|
|
|
#include "minitext.h"
|
|
|
|
|
#include "missiles.h"
|
|
|
|
|
#include "msg.h"
|
|
|
|
|
#include "multi.h"
|
|
|
|
|
#include "objects.h"
|
|
|
|
|
#include "player.h"
|
|
|
|
|
#include "portal.h"
|
|
|
|
|
#include "qol/chatlog.h"
|
|
|
|
|
#include "spelldat.h"
|
|
|
|
|
#include "stores.h"
|
|
|
|
|
#include "towners.h"
|
|
|
|
|
|
|
|
|
|
namespace DAPI {
|
|
|
|
|
enum struct CommandType {
|
|
|
|
|
STAND,
|
|
|
|
|
WALKXY,
|
|
|
|
|
ACK_PLRINFO,
|
|
|
|
|
ADDSTR,
|
|
|
|
|
ADDMAG,
|
|
|
|
|
ADDDEX,
|
|
|
|
|
ADDVIT,
|
|
|
|
|
SBSPELL,
|
|
|
|
|
GETITEM,
|
|
|
|
|
AGETITEM,
|
|
|
|
|
PUTITEM,
|
|
|
|
|
RESPAWNITEM,
|
|
|
|
|
ATTACKXY,
|
|
|
|
|
RATTACKXY,
|
|
|
|
|
SPELLXY,
|
|
|
|
|
TSPELLXY,
|
|
|
|
|
OPOBJXY,
|
|
|
|
|
DISARMXY,
|
|
|
|
|
ATTACKID,
|
|
|
|
|
ATTACKPID,
|
|
|
|
|
RATTACKID,
|
|
|
|
|
RATTACKPID,
|
|
|
|
|
SPELLID,
|
|
|
|
|
SPELL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 = 20,
|
|
|
|
|
INV15 = 21,
|
|
|
|
|
INV16 = 22,
|
|
|
|
|
INV17 = 23,
|
|
|
|
|
INV18 = 24,
|
|
|
|
|
INV19 = 25,
|
|
|
|
|
INV20 = 26,
|
|
|
|
|
INV21 = 27,
|
|
|
|
|
INV22 = 28,
|
|
|
|
|
INV23 = 29,
|
|
|
|
|
INV24 = 30,
|
|
|
|
|
INV25 = 31,
|
|
|
|
|
INV26 = 32,
|
|
|
|
|
INV27 = 33,
|
|
|
|
|
INV28 = 34,
|
|
|
|
|
INV29 = 35,
|
|
|
|
|
INV30 = 36,
|
|
|
|
|
INV31 = 37,
|
|
|
|
|
INV32 = 38,
|
|
|
|
|
INV33 = 39,
|
|
|
|
|
INV34 = 40,
|
|
|
|
|
INV35 = 41,
|
|
|
|
|
INV36 = 42,
|
|
|
|
|
INV37 = 43,
|
|
|
|
|
INV38 = 44,
|
|
|
|
|
INV39 = 45,
|
|
|
|
|
INV40 = 46,
|
|
|
|
|
BELT1 = 47,
|
|
|
|
|
BELT2 = 48,
|
|
|
|
|
BELT3 = 49,
|
|
|
|
|
BELT4 = 50,
|
|
|
|
|
BELT5 = 51,
|
|
|
|
|
BELT6 = 52,
|
|
|
|
|
BELT7 = 53,
|
|
|
|
|
BELT8 = 54
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
enum struct Backend {
|
|
|
|
|
Vanilla109,
|
|
|
|
|
DevilutionX
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
struct Server {
|
|
|
|
|
Server();
|
|
|
|
|
|
|
|
|
|
Server(const Server &other) = delete;
|
|
|
|
|
Server(Server &&other) = delete;
|
|
|
|
|
|
|
|
|
|
void update();
|
|
|
|
|
bool isConnected() const;
|
|
|
|
|
|
|
|
|
|
int FPS;
|
|
|
|
|
std::ofstream output;
|
|
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
void processMessages();
|
|
|
|
|
void checkForConnections();
|
|
|
|
|
void updateGameData();
|
|
|
|
|
bool isOnScreen(int x, int y);
|
|
|
|
|
bool OKToAct();
|
|
|
|
|
void move(int x, int y);
|
|
|
|
|
void talk(int x, int y);
|
|
|
|
|
void selectStoreOption(StoreOption option);
|
|
|
|
|
void buyItem(int itemID);
|
|
|
|
|
void sellItem(int itemID);
|
|
|
|
|
void rechargeItem(int itemID);
|
|
|
|
|
void repairItem(int itemID);
|
|
|
|
|
void attackMonster(int index);
|
|
|
|
|
void attackXY(int x, int y);
|
|
|
|
|
void operateObject(int index);
|
|
|
|
|
void useBeltItem(int slot);
|
|
|
|
|
void toggleCharacterScreen();
|
|
|
|
|
void increaseStat(CommandType commandType);
|
|
|
|
|
void getItem(int itemID);
|
|
|
|
|
void setSpell(int spellID, devilution::SpellType spellType);
|
|
|
|
|
void castSpell(int index);
|
|
|
|
|
void toggleInventory();
|
|
|
|
|
void putInCursor(size_t itemID);
|
|
|
|
|
void putCursorItem(int location);
|
|
|
|
|
void dropCursorItem();
|
|
|
|
|
void useItem(size_t itemID);
|
|
|
|
|
void identifyStoreItem(int itemID);
|
|
|
|
|
void castSpell(int x, int y);
|
|
|
|
|
void cancelQText();
|
|
|
|
|
void setFPS(int newFPS);
|
|
|
|
|
void disarmTrap(int index);
|
|
|
|
|
void skillRepair(int itemID);
|
|
|
|
|
void skillRecharge(int itemID);
|
|
|
|
|
void toggleMenu();
|
|
|
|
|
void saveGame();
|
|
|
|
|
void quit();
|
|
|
|
|
void clearCursor();
|
|
|
|
|
void identifyItem(int itemID);
|
|
|
|
|
void sendChat(std::string message);
|
|
|
|
|
|
|
|
|
|
bool listening = false;
|
|
|
|
|
|
|
|
|
|
std::unique_ptr<GameData> data;
|
|
|
|
|
|
|
|
|
|
std::map<std::pair<int, int>, bool> panelScreenCheck;
|
|
|
|
|
|
|
|
|
|
DAPIProtoClient protoClient;
|
|
|
|
|
};
|
|
|
|
|
} // namespace DAPI
|