35 changed files with 4417 additions and 451 deletions
@ -0,0 +1,12 @@ |
|||||||
|
include(functions/FetchContent_ExcludeFromAll_backport) |
||||||
|
|
||||||
|
set(SFML_BUILD_WINDOW OFF) |
||||||
|
set(SFML_BUILD_GRAPHICS OFF) |
||||||
|
set(SFML_BUILD_AUDIO OFF) |
||||||
|
|
||||||
|
include(FetchContent) |
||||||
|
FetchContent_Declare_ExcludeFromAll(sfml |
||||||
|
GIT_REPOSITORY https://github.com/SFML/SFML |
||||||
|
GIT_TAG 016bea9491ccafc3529019fe1d403885a8b3a6ae |
||||||
|
) |
||||||
|
FetchContent_MakeAvailable_ExcludeFromAll(sfml) |
||||||
@ -0,0 +1,214 @@ |
|||||||
|
#include <thread> |
||||||
|
|
||||||
|
#include "DAPIProtoClient.h" |
||||||
|
|
||||||
|
namespace DAPI { |
||||||
|
DAPIProtoClient::DAPIProtoClient() |
||||||
|
: mt(static_cast<unsigned int>(std::chrono::system_clock::now().time_since_epoch().count())) |
||||||
|
{ |
||||||
|
udpbound = false; |
||||||
|
connectionPort = 1025; |
||||||
|
} |
||||||
|
|
||||||
|
void DAPIProtoClient::checkForConnection() |
||||||
|
{ |
||||||
|
if (isConnected()) |
||||||
|
return; |
||||||
|
|
||||||
|
sf::Packet packet; |
||||||
|
udpSocket.setBlocking(false); |
||||||
|
if (!udpbound) { |
||||||
|
if (udpSocket.bind(1024, sf::IpAddress::Any) != sf::Socket::Status::Done) |
||||||
|
return; |
||||||
|
udpbound = true; |
||||||
|
} |
||||||
|
|
||||||
|
std::optional<sf::IpAddress> sender = sf::IpAddress::Any; |
||||||
|
auto port = udpSocket.getLocalPort(); |
||||||
|
if (udpSocket.receive(packet, sender, port) != sf::Socket::Status::Done) |
||||||
|
return; |
||||||
|
|
||||||
|
auto size = packet.getDataSize(); |
||||||
|
std::unique_ptr<char[]> packetContents(new char[size]); |
||||||
|
memcpy(packetContents.get(), packet.getData(), size); |
||||||
|
|
||||||
|
auto currentMessage = std::make_unique<dapi::message::Message>(); |
||||||
|
currentMessage->ParseFromArray(packetContents.get(), static_cast<int>(size)); |
||||||
|
|
||||||
|
if (!currentMessage->has_initbroadcast()) |
||||||
|
return; |
||||||
|
|
||||||
|
auto reply = std::make_unique<dapi::message::Message>(); |
||||||
|
auto initResponse = reply->mutable_initresponse(); |
||||||
|
|
||||||
|
initResponse->set_port(static_cast<int>(connectionPort)); |
||||||
|
|
||||||
|
packet.clear(); |
||||||
|
size = reply->ByteSizeLong(); |
||||||
|
std::unique_ptr<char[]> buffer(new char[size]); |
||||||
|
|
||||||
|
reply->SerializeToArray(&buffer[0], static_cast<int>(size)); |
||||||
|
packet.append(buffer.get(), size); |
||||||
|
|
||||||
|
udpSocket.send(packet, sender.value(), port); |
||||||
|
udpSocket.unbind(); |
||||||
|
udpbound = false; |
||||||
|
|
||||||
|
tcpListener.accept(tcpSocket); |
||||||
|
return; |
||||||
|
} |
||||||
|
|
||||||
|
void DAPIProtoClient::lookForServer() |
||||||
|
{ |
||||||
|
if (isConnected()) |
||||||
|
return; |
||||||
|
|
||||||
|
sf::Packet packet; |
||||||
|
auto broadcastMessage = std::make_unique<dapi::message::Message>(); |
||||||
|
broadcastMessage->mutable_initbroadcast(); |
||||||
|
|
||||||
|
auto size = broadcastMessage->ByteSizeLong(); |
||||||
|
std::unique_ptr<char[]> buffer(new char[size]); |
||||||
|
|
||||||
|
broadcastMessage->SerializeToArray(&buffer[0], size); |
||||||
|
packet.append(buffer.get(), size); |
||||||
|
|
||||||
|
std::optional<sf::IpAddress> server = sf::IpAddress::Broadcast; |
||||||
|
unsigned short port = 1024; |
||||||
|
|
||||||
|
udpSocket.send(packet, server.value(), port); |
||||||
|
server = sf::IpAddress::Any; |
||||||
|
udpSocket.setBlocking(false); |
||||||
|
// Sleep to give backend a chance to send the packet.
|
||||||
|
{ |
||||||
|
using namespace std::chrono_literals; |
||||||
|
std::this_thread::sleep_for(2s); |
||||||
|
} |
||||||
|
if (udpSocket.receive(packet, server, port) == sf::Socket::Status::Done) { |
||||||
|
size = packet.getDataSize(); |
||||||
|
std::unique_ptr<char[]> replyBuffer(new char[size]); |
||||||
|
memcpy(replyBuffer.get(), packet.getData(), size); |
||||||
|
|
||||||
|
auto currentMessage = std::make_unique<dapi::message::Message>(); |
||||||
|
currentMessage->ParseFromArray(replyBuffer.get(), size); |
||||||
|
|
||||||
|
if (!currentMessage->has_initresponse()) |
||||||
|
return; |
||||||
|
|
||||||
|
connectionPort = static_cast<unsigned short>(currentMessage->initresponse().port()); |
||||||
|
|
||||||
|
tcpSocket.connect(server.value(), connectionPort); |
||||||
|
if (!tcpSocket.getRemoteAddress().has_value()) |
||||||
|
fprintf(stderr, "%s", "Connection failed.\n"); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void DAPIProtoClient::transmitMessages() |
||||||
|
{ |
||||||
|
// Check that we are connected to a game server.
|
||||||
|
if (!isConnected()) |
||||||
|
return; |
||||||
|
|
||||||
|
std::unique_ptr<dapi::message::Message> currentMessage; |
||||||
|
sf::Packet packet; |
||||||
|
// Loop until the message queue is empty.
|
||||||
|
while (!messageQueue.empty()) { |
||||||
|
packet.clear(); |
||||||
|
currentMessage = std::move(messageQueue.front()); |
||||||
|
messageQueue.pop_front(); |
||||||
|
auto size = currentMessage->ByteSizeLong(); |
||||||
|
if (size > 0) { |
||||||
|
std::unique_ptr<char[]> buffer(new char[size]); |
||||||
|
currentMessage->SerializeToArray(&buffer[0], size); |
||||||
|
packet.append(buffer.get(), size); |
||||||
|
} |
||||||
|
if (tcpSocket.send(packet) != sf::Socket::Status::Done) { |
||||||
|
// Error sending message.
|
||||||
|
fprintf(stderr, "Failed to send a Message. Disconnecting.\n"); |
||||||
|
disconnect(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
// Finished with queue, send the EndOfQueue message.
|
||||||
|
currentMessage = std::make_unique<dapi::message::Message>(); |
||||||
|
currentMessage->mutable_endofqueue(); |
||||||
|
packet.clear(); |
||||||
|
auto size = currentMessage->ByteSizeLong(); |
||||||
|
std::unique_ptr<char[]> buffer(new char[size]); |
||||||
|
currentMessage->SerializeToArray(&buffer[0], size); |
||||||
|
packet.append(buffer.get(), size); |
||||||
|
if (tcpSocket.send(packet) != sf::Socket::Status::Done) { |
||||||
|
// Error sending EndOfQueue
|
||||||
|
fprintf(stderr, "Failed to send end of queue message. Disconnecting.\n"); |
||||||
|
disconnect(); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void DAPIProtoClient::receiveMessages() |
||||||
|
{ |
||||||
|
// Check that we are connected to a game server or client.
|
||||||
|
if (!isConnected()) |
||||||
|
return; |
||||||
|
|
||||||
|
std::unique_ptr<dapi::message::Message> currentMessage; |
||||||
|
sf::Packet packet; |
||||||
|
// Loop until the end of queue message is received.
|
||||||
|
while (true) { |
||||||
|
packet.clear(); |
||||||
|
currentMessage = std::make_unique<dapi::message::Message>(); |
||||||
|
if (tcpSocket.receive(packet) != sf::Socket::Status::Done) { |
||||||
|
fprintf(stderr, "Failed to receive message. Disconnecting.\n"); |
||||||
|
disconnect(); |
||||||
|
return; |
||||||
|
} |
||||||
|
auto size = packet.getDataSize(); |
||||||
|
std::unique_ptr<char[]> packetContents(new char[size]); |
||||||
|
memcpy(packetContents.get(), packet.getData(), size); |
||||||
|
currentMessage->ParseFromArray(packetContents.get(), packet.getDataSize()); |
||||||
|
if (currentMessage->has_endofqueue()) |
||||||
|
return; |
||||||
|
messageQueue.push_back(std::move(currentMessage)); |
||||||
|
} |
||||||
|
} |
||||||
|
|
||||||
|
void DAPIProtoClient::disconnect() |
||||||
|
{ |
||||||
|
if (!isConnected()) |
||||||
|
return; |
||||||
|
tcpSocket.disconnect(); |
||||||
|
} |
||||||
|
|
||||||
|
void DAPIProtoClient::initListen() |
||||||
|
{ |
||||||
|
tcpListener.setBlocking(true); |
||||||
|
while (tcpListener.listen(connectionPort) != sf::Socket::Status::Done) |
||||||
|
connectionPort = static_cast<unsigned short>(getRandomInteger(1025, 49151)); |
||||||
|
} |
||||||
|
|
||||||
|
void DAPIProtoClient::stopListen() |
||||||
|
{ |
||||||
|
tcpListener.close(); |
||||||
|
} |
||||||
|
|
||||||
|
void DAPIProtoClient::queueMessage(std::unique_ptr<dapi::message::Message> newMessage) |
||||||
|
{ |
||||||
|
messageQueue.push_back(std::move(newMessage)); |
||||||
|
} |
||||||
|
|
||||||
|
std::unique_ptr<dapi::message::Message> DAPIProtoClient::getNextMessage() |
||||||
|
{ |
||||||
|
auto nextMessage = std::move(messageQueue.front()); |
||||||
|
messageQueue.pop_front(); |
||||||
|
return nextMessage; |
||||||
|
} |
||||||
|
|
||||||
|
bool DAPIProtoClient::isConnected() const |
||||||
|
{ |
||||||
|
return tcpSocket.getRemoteAddress().has_value(); |
||||||
|
} |
||||||
|
|
||||||
|
int DAPIProtoClient::messageQueueSize() const |
||||||
|
{ |
||||||
|
return messageQueue.size(); |
||||||
|
} |
||||||
|
} // namespace DAPI
|
||||||
@ -0,0 +1,45 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include <deque> |
||||||
|
#include <random> |
||||||
|
|
||||||
|
#include <SFML/Network.hpp> |
||||||
|
|
||||||
|
#include "message.pb.h" |
||||||
|
|
||||||
|
namespace DAPI { |
||||||
|
struct DAPIProtoClient { |
||||||
|
DAPIProtoClient(); |
||||||
|
|
||||||
|
void checkForConnection(); |
||||||
|
void lookForServer(); |
||||||
|
void transmitMessages(); |
||||||
|
void receiveMessages(); |
||||||
|
void disconnect(); |
||||||
|
void initListen(); |
||||||
|
void stopListen(); |
||||||
|
|
||||||
|
void queueMessage(std::unique_ptr<dapi::message::Message> newMessage); |
||||||
|
std::unique_ptr<dapi::message::Message> getNextMessage(); |
||||||
|
|
||||||
|
bool isConnected() const; |
||||||
|
int messageQueueSize() const; |
||||||
|
|
||||||
|
private: |
||||||
|
sf::UdpSocket udpSocket; |
||||||
|
sf::TcpSocket tcpSocket; |
||||||
|
sf::TcpListener tcpListener; |
||||||
|
sf::SocketSelector socketSelector; |
||||||
|
std::deque<std::unique_ptr<dapi::message::Message>> messageQueue; |
||||||
|
std::mt19937 mt; |
||||||
|
|
||||||
|
int getRandomInteger(int min, int max) |
||||||
|
{ |
||||||
|
std::uniform_int_distribution<int> randomNumber(min, max); |
||||||
|
return randomNumber(mt); |
||||||
|
} |
||||||
|
|
||||||
|
unsigned short connectionPort; |
||||||
|
bool udpbound; |
||||||
|
}; |
||||||
|
} // namespace DAPI
|
||||||
@ -0,0 +1,185 @@ |
|||||||
|
syntax = "proto3"; |
||||||
|
option optimize_for = LITE_RUNTIME; |
||||||
|
|
||||||
|
package dapi.commands; |
||||||
|
|
||||||
|
message SetFPS { |
||||||
|
uint32 FPS = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message CancelQText { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
message Move { |
||||||
|
uint32 type = 1; |
||||||
|
uint32 targetX = 2; |
||||||
|
uint32 targetY = 3; |
||||||
|
} |
||||||
|
|
||||||
|
message Talk { |
||||||
|
uint32 targetX = 1; |
||||||
|
uint32 targetY = 2; |
||||||
|
} |
||||||
|
|
||||||
|
message SelectStoreOption { |
||||||
|
uint32 option = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message BuyItem { |
||||||
|
uint32 ID = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message SellItem { |
||||||
|
uint32 ID = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message RechargeItem { |
||||||
|
uint32 ID = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message RepairItem { |
||||||
|
uint32 ID = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message AttackMonster { |
||||||
|
uint32 index = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message AttackXY { |
||||||
|
sint32 x = 1; |
||||||
|
sint32 y = 2; |
||||||
|
} |
||||||
|
|
||||||
|
message OperateObject { |
||||||
|
uint32 index = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message UseBeltItem { |
||||||
|
uint32 slot = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message ToggleCharacterSheet { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
message IncreaseStat { |
||||||
|
uint32 stat = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message GetItem { |
||||||
|
uint32 ID = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message SetSpell { |
||||||
|
sint32 spellID = 1; |
||||||
|
sint32 spellType = 2; |
||||||
|
} |
||||||
|
|
||||||
|
message CastMonster { |
||||||
|
uint32 index = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message CastXY { |
||||||
|
sint32 x = 1; |
||||||
|
sint32 y = 2; |
||||||
|
} |
||||||
|
|
||||||
|
message ToggleInventory { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
message PutInCursor { |
||||||
|
uint32 ID = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message PutCursorItem { |
||||||
|
sint32 target = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message DropCursorItem { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
message UseItem { |
||||||
|
uint32 ID = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message IdentifyStoreItem { |
||||||
|
uint32 ID = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message DisarmTrap { |
||||||
|
uint32 index = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message SkillRepair { |
||||||
|
uint32 ID = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message SkillRecharge { |
||||||
|
uint32 ID = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message ToggleMenu { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
message SaveGame { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
message Quit { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
message ClearCursor { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
message IdentifyItem { |
||||||
|
uint32 ID = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message SendChat { |
||||||
|
string message = 1; |
||||||
|
} |
||||||
|
|
||||||
|
message Command { |
||||||
|
oneof command { |
||||||
|
Move move = 1; |
||||||
|
Talk talk = 2; |
||||||
|
SelectStoreOption option = 3; |
||||||
|
BuyItem buyItem = 4; |
||||||
|
SellItem sellItem = 5; |
||||||
|
RechargeItem rechargeItem = 6; |
||||||
|
RepairItem repairItem = 7; |
||||||
|
AttackMonster attackMonster = 8; |
||||||
|
AttackXY attackXY = 9; |
||||||
|
OperateObject operateObject = 10; |
||||||
|
UseBeltItem useBeltItem = 11; |
||||||
|
ToggleCharacterSheet toggleCharacterSheet = 12; |
||||||
|
IncreaseStat increaseStat = 13; |
||||||
|
GetItem getItem = 14; |
||||||
|
SetSpell setSpell = 15; |
||||||
|
CastMonster castMonster = 16; |
||||||
|
CastXY castXY = 17; |
||||||
|
ToggleInventory toggleInventory = 18; |
||||||
|
PutInCursor putInCursor = 19; |
||||||
|
PutCursorItem putCursorItem = 20; |
||||||
|
DropCursorItem dropCursorItem = 21; |
||||||
|
UseItem useItem = 22; |
||||||
|
IdentifyStoreItem identifyStoreItem = 23; |
||||||
|
CancelQText cancelQText = 24; |
||||||
|
SetFPS setFPS = 25; |
||||||
|
DisarmTrap disarmTrap = 26; |
||||||
|
SkillRepair skillRepair = 27; |
||||||
|
SkillRecharge skillRecharge = 28; |
||||||
|
ToggleMenu toggleMenu = 29; |
||||||
|
SaveGame saveGame = 30; |
||||||
|
Quit quit = 31; |
||||||
|
ClearCursor clearCursor = 32; |
||||||
|
IdentifyItem identifyItem = 33; |
||||||
|
SendChat sendChat = 34; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,179 @@ |
|||||||
|
syntax = "proto3"; |
||||||
|
option optimize_for = LITE_RUNTIME; |
||||||
|
|
||||||
|
package dapi.data; |
||||||
|
|
||||||
|
message QuestData { |
||||||
|
uint32 id = 1; |
||||||
|
uint32 state = 2; |
||||||
|
} |
||||||
|
|
||||||
|
message PortalData { |
||||||
|
uint32 x = 1; |
||||||
|
uint32 y = 2; |
||||||
|
uint32 player = 3; |
||||||
|
} |
||||||
|
|
||||||
|
message MissileData { |
||||||
|
sint32 type = 1; |
||||||
|
uint32 x = 2; |
||||||
|
uint32 y = 3; |
||||||
|
sint32 xvel = 4; |
||||||
|
sint32 yvel = 5; |
||||||
|
sint32 sx = 6; |
||||||
|
sint32 sy = 7; |
||||||
|
} |
||||||
|
|
||||||
|
message ObjectData { |
||||||
|
uint32 x = 1; |
||||||
|
uint32 y = 2; |
||||||
|
sint32 type = 3; |
||||||
|
sint32 shrineType = 4; |
||||||
|
bool solid = 5; |
||||||
|
sint32 doorState = 6; |
||||||
|
bool selectable = 7; |
||||||
|
uint32 index = 8; |
||||||
|
bool trapped = 9; |
||||||
|
} |
||||||
|
|
||||||
|
message MonsterData { |
||||||
|
uint32 index = 1; |
||||||
|
sint32 x = 2; |
||||||
|
sint32 y = 3; |
||||||
|
sint32 futx = 4; |
||||||
|
sint32 futy = 5; |
||||||
|
string name = 6; |
||||||
|
sint32 type = 7; |
||||||
|
sint32 kills = 8; |
||||||
|
sint32 mode = 9; |
||||||
|
bool unique = 10; |
||||||
|
} |
||||||
|
|
||||||
|
message TriggerData { |
||||||
|
uint32 lvl = 1; |
||||||
|
sint32 x = 2; |
||||||
|
sint32 y = 3; |
||||||
|
sint32 type = 4; |
||||||
|
} |
||||||
|
|
||||||
|
message TileData { |
||||||
|
sint32 type = 1; |
||||||
|
bool solid = 2; |
||||||
|
sint32 x = 3; |
||||||
|
sint32 y = 4; |
||||||
|
bool stopMissile = 5; |
||||||
|
} |
||||||
|
|
||||||
|
message TownerData { |
||||||
|
uint32 ID = 1; |
||||||
|
uint32 _ttype = 2; |
||||||
|
sint32 _tx = 3; |
||||||
|
sint32 _ty = 4; |
||||||
|
string _tName = 5; |
||||||
|
} |
||||||
|
|
||||||
|
message ItemData { |
||||||
|
uint32 ID = 1; |
||||||
|
sint32 _itype = 2; |
||||||
|
sint32 _ix = 3; |
||||||
|
sint32 _iy = 4; |
||||||
|
|
||||||
|
bool _iIdentified = 5; |
||||||
|
uint32 _iMagical = 6; |
||||||
|
string _iName = 7; |
||||||
|
string _iIName = 8; |
||||||
|
uint32 _iClass = 9; |
||||||
|
sint32 _iCurs = 10; |
||||||
|
sint32 _iValue = 11; |
||||||
|
sint32 _iMinDam = 12; |
||||||
|
sint32 _iMaxDam = 13; |
||||||
|
sint32 _iAC = 14; |
||||||
|
sint32 _iFlags = 15; |
||||||
|
sint32 _iMiscId = 16; |
||||||
|
sint32 _iSpell = 17; |
||||||
|
sint32 _iCharges = 18; |
||||||
|
sint32 _iMaxCharges = 19; |
||||||
|
sint32 _iDurability = 20; |
||||||
|
sint32 _iMaxDur = 21; |
||||||
|
sint32 _iPLDam = 22; |
||||||
|
sint32 _iPLToHit = 23; |
||||||
|
sint32 _iPLAC = 24; |
||||||
|
sint32 _iPLStr = 25; |
||||||
|
sint32 _iPLMag = 26; |
||||||
|
sint32 _iPLDex = 27; |
||||||
|
sint32 _iPLVit = 28; |
||||||
|
sint32 _iPLFR = 29; |
||||||
|
sint32 _iPLLR = 30; |
||||||
|
sint32 _iPLMR = 31; |
||||||
|
sint32 _iPLMana = 32; |
||||||
|
sint32 _iPLHP = 33; |
||||||
|
sint32 _iPLDamMod = 34; |
||||||
|
sint32 _iPLGetHit = 35; |
||||||
|
sint32 _iPLLight = 36; |
||||||
|
sint32 _iSplLvlAdd = 37; |
||||||
|
sint32 _iFMinDam = 38; |
||||||
|
sint32 _iFMaxDam = 39; |
||||||
|
sint32 _iLMinDam = 40; |
||||||
|
sint32 _iLMaxDam = 41; |
||||||
|
sint32 _iPrePower = 42; |
||||||
|
sint32 _iSufPower = 43; |
||||||
|
sint32 _iMinStr = 44; |
||||||
|
sint32 _iMinMag = 45; |
||||||
|
sint32 _iMinDex = 46; |
||||||
|
bool _iStatFlag = 47; |
||||||
|
sint32 IDidx = 48; |
||||||
|
} |
||||||
|
|
||||||
|
message PlayerData { |
||||||
|
sint32 _pmode = 1; |
||||||
|
sint32 pnum = 2; |
||||||
|
sint32 plrlevel = 3; |
||||||
|
sint32 _px = 4; |
||||||
|
sint32 _py = 5; |
||||||
|
sint32 _pfutx = 6; |
||||||
|
sint32 _pfuty = 7; |
||||||
|
sint32 _pdir = 8; |
||||||
|
sint32 _pRSpell = 9; |
||||||
|
uint32 _pRsplType = 10; |
||||||
|
repeated uint32 _pSplLvl = 11; |
||||||
|
uint64 _pMemSpells = 12; |
||||||
|
uint64 _pAblSpells = 13; |
||||||
|
uint64 _pScrlSpells = 14; |
||||||
|
string _pName = 15; |
||||||
|
uint32 _pClass = 16; |
||||||
|
uint32 _pStrength = 17; |
||||||
|
uint32 _pBaseStr = 18; |
||||||
|
uint32 _pMagic = 19; |
||||||
|
uint32 _pBaseMag = 20; |
||||||
|
uint32 _pDexterity = 21; |
||||||
|
uint32 _pBaseDex = 22; |
||||||
|
uint32 _pVitality = 23; |
||||||
|
uint32 _pBaseVit = 24; |
||||||
|
uint32 _pStatPts = 25; |
||||||
|
uint32 _pDamageMod = 26; |
||||||
|
uint32 _pHitPoints = 27; |
||||||
|
uint32 _pMaxHP = 28; |
||||||
|
sint32 _pMana = 29; |
||||||
|
uint32 _pMaxMana = 30; |
||||||
|
uint32 _pLevel = 31; |
||||||
|
uint32 _pExperience = 32; |
||||||
|
uint32 _pArmorClass = 33; |
||||||
|
uint32 _pMagResist = 34; |
||||||
|
uint32 _pFireResist = 35; |
||||||
|
uint32 _pLightResist = 36; |
||||||
|
uint32 _pGold = 37; |
||||||
|
repeated sint32 InvBody = 38; |
||||||
|
repeated sint32 InvList = 39; |
||||||
|
repeated sint32 InvGrid = 40; |
||||||
|
repeated sint32 SpdList = 41; |
||||||
|
sint32 HoldItem = 42; |
||||||
|
uint32 _pIAC = 43; |
||||||
|
uint32 _pIMinDam = 44; |
||||||
|
uint32 _pIMaxDam = 45; |
||||||
|
uint32 _pIBonusDam = 46; |
||||||
|
uint32 _pIBonusToHit = 47; |
||||||
|
uint32 _pIBonusAC = 48; |
||||||
|
uint32 _pIBonusDamMod = 49; |
||||||
|
int32 _pISplLvlAdd = 50; |
||||||
|
bool pManaShield = 51; |
||||||
|
} |
||||||
@ -0,0 +1,40 @@ |
|||||||
|
syntax = "proto3"; |
||||||
|
option optimize_for = LITE_RUNTIME; |
||||||
|
import "data.proto"; |
||||||
|
|
||||||
|
package dapi.game; |
||||||
|
|
||||||
|
message FrameUpdate { |
||||||
|
uint32 player = 1; |
||||||
|
sint32 stextflag = 2; |
||||||
|
sint32 pauseMode = 3; |
||||||
|
bool menuOpen = 4; |
||||||
|
uint32 cursor = 5; |
||||||
|
bool chrflag = 6; |
||||||
|
bool invflag = 7; |
||||||
|
bool qtextflag = 8; |
||||||
|
string qtext = 9; |
||||||
|
uint32 currlevel = 10; |
||||||
|
bool setlevel = 11; |
||||||
|
uint32 fps = 12; |
||||||
|
uint32 gameMode = 13; |
||||||
|
uint32 gnDifficulty = 14; |
||||||
|
uint32 connectedTo = 15; |
||||||
|
uint32 stashGold = 16; |
||||||
|
|
||||||
|
repeated dapi.data.TileData dPiece = 17; |
||||||
|
repeated dapi.data.PlayerData playerData = 18; |
||||||
|
repeated dapi.data.ItemData itemData = 19; |
||||||
|
repeated uint32 groundItemID = 20; |
||||||
|
repeated dapi.data.TownerData townerData = 21; |
||||||
|
repeated uint32 storeOption = 22; |
||||||
|
repeated uint32 storeItems = 23; |
||||||
|
repeated uint32 stashItems = 24; |
||||||
|
repeated dapi.data.TriggerData triggerData = 25; |
||||||
|
repeated dapi.data.MonsterData monsterData = 26; |
||||||
|
repeated dapi.data.ObjectData objectData = 27; |
||||||
|
repeated dapi.data.MissileData missileData = 28; |
||||||
|
repeated dapi.data.PortalData portalData = 29; |
||||||
|
repeated dapi.data.QuestData questData = 30; |
||||||
|
repeated string chatMessages = 31; |
||||||
|
} |
||||||
@ -0,0 +1,12 @@ |
|||||||
|
syntax = "proto3"; |
||||||
|
option optimize_for = LITE_RUNTIME; |
||||||
|
|
||||||
|
package dapi.init; |
||||||
|
|
||||||
|
message ClientBroadcast { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
message ServerResponse { |
||||||
|
uint32 port = 1; |
||||||
|
} |
||||||
@ -0,0 +1,26 @@ |
|||||||
|
syntax = "proto3"; |
||||||
|
option optimize_for = LITE_RUNTIME; |
||||||
|
import "init.proto"; |
||||||
|
import "game.proto"; |
||||||
|
import "command.proto"; |
||||||
|
|
||||||
|
package dapi.message; |
||||||
|
|
||||||
|
// Empty message to intidate end of queue |
||||||
|
message EndofQueue { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
// Wrapper used to distinguish which message is which |
||||||
|
message Message{ |
||||||
|
oneof msg { |
||||||
|
dapi.init.ClientBroadcast initBroadcast = 1; |
||||||
|
dapi.init.ServerResponse initResponse = 2; |
||||||
|
|
||||||
|
dapi.game.FrameUpdate frameUpdate = 3; |
||||||
|
|
||||||
|
dapi.commands.Command command = 4; |
||||||
|
|
||||||
|
EndofQueue endOfQueue = 5; |
||||||
|
} |
||||||
|
} |
||||||
@ -0,0 +1,47 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include <map> |
||||||
|
#include <vector> |
||||||
|
|
||||||
|
#include "Item.h" |
||||||
|
#include "Player.h" |
||||||
|
#include "Towner.h" |
||||||
|
#include "Trigger.h" |
||||||
|
|
||||||
|
namespace DAPI { |
||||||
|
enum struct StoreOption { |
||||||
|
TALK, |
||||||
|
IDENTIFYANITEM, |
||||||
|
EXIT, |
||||||
|
HEAL, |
||||||
|
BUYITEMS, |
||||||
|
WIRTPEEK, |
||||||
|
BUYBASIC, |
||||||
|
BUYPREMIUM, |
||||||
|
SELL, |
||||||
|
REPAIR, |
||||||
|
RECHARGE, |
||||||
|
BACK, |
||||||
|
ACCESSSTORAGE |
||||||
|
}; |
||||||
|
|
||||||
|
struct GameData { |
||||||
|
bool menuOpen; |
||||||
|
int pcurs; |
||||||
|
bool chrflag; |
||||||
|
bool invflag; |
||||||
|
bool qtextflag; |
||||||
|
int currlevel; |
||||||
|
int stashGold; |
||||||
|
size_t lastLogSize; |
||||||
|
|
||||||
|
std::map<int, PlayerData> playerList; |
||||||
|
std::vector<ItemData> itemList; |
||||||
|
std::vector<int> groundItems; |
||||||
|
std::vector<int> stashItems; |
||||||
|
std::map<int, TownerData> townerList; |
||||||
|
std::vector<StoreOption> storeList; |
||||||
|
std::vector<int> storeItems; |
||||||
|
std::vector<TriggerData> triggerList; |
||||||
|
}; |
||||||
|
} // namespace DAPI
|
||||||
@ -0,0 +1,71 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include "../items.h" |
||||||
|
|
||||||
|
namespace DAPI { |
||||||
|
struct ItemData { |
||||||
|
bool compare(devilution::Item &item) |
||||||
|
{ |
||||||
|
return item._iSeed == _iSeed && item._iCreateInfo == _iCreateInfo && item.IDidx == IDidx; |
||||||
|
} |
||||||
|
|
||||||
|
int ID; |
||||||
|
|
||||||
|
uint32_t _iSeed; |
||||||
|
int _iCreateInfo; |
||||||
|
int _itype; |
||||||
|
int _ix; |
||||||
|
int _iy; |
||||||
|
|
||||||
|
uint32_t _iIdentified; |
||||||
|
char _iMagical; |
||||||
|
char _iName[64]; |
||||||
|
char _iIName[64]; |
||||||
|
char _iClass; |
||||||
|
int _iCurs; |
||||||
|
int _ivalue; |
||||||
|
int _iMinDam; |
||||||
|
int _iMaxDam; |
||||||
|
int _iAC; |
||||||
|
int _iFlags; |
||||||
|
int _iMiscId; |
||||||
|
int _iSpell; |
||||||
|
|
||||||
|
int _iCharges; |
||||||
|
int _iMaxCharges; |
||||||
|
|
||||||
|
int _iDurability; |
||||||
|
int _iMaxDur; |
||||||
|
|
||||||
|
int _iPLDam; |
||||||
|
int _iPLToHit; |
||||||
|
int _iPLAC; |
||||||
|
int _iPLStr; |
||||||
|
int _iPLMag; |
||||||
|
int _iPLDex; |
||||||
|
int _iPLVit; |
||||||
|
int _iPLFR; |
||||||
|
int _iPLLR; |
||||||
|
int _iPLMR; |
||||||
|
int _iPLMana; |
||||||
|
int _iPLHP; |
||||||
|
int _iPLDamMod; |
||||||
|
int _iPLGetHit; |
||||||
|
int _iPLLight; |
||||||
|
char _iSplLvlAdd; |
||||||
|
|
||||||
|
int _iFMinDam; |
||||||
|
int _iFMaxDam; |
||||||
|
int _iLMinDam; |
||||||
|
int _iLMaxDam; |
||||||
|
|
||||||
|
char _iPrePower; |
||||||
|
char _iSufPower; |
||||||
|
|
||||||
|
char _iMinStr; |
||||||
|
char _iMinMag; |
||||||
|
char _iMinDex; |
||||||
|
uint32_t _iStatFlag; |
||||||
|
int IDidx; |
||||||
|
}; |
||||||
|
} // namespace DAPI
|
||||||
@ -0,0 +1,75 @@ |
|||||||
|
#pragma once |
||||||
|
#include "Item.h" |
||||||
|
#include <map> |
||||||
|
|
||||||
|
namespace DAPI { |
||||||
|
const int NUM_INVLOC = 7; |
||||||
|
const int MAXINV = 40; |
||||||
|
const int MAXSPD = 8; |
||||||
|
|
||||||
|
struct PlayerData { |
||||||
|
int _pmode; |
||||||
|
int pnum; |
||||||
|
int plrlevel; |
||||||
|
int _px; |
||||||
|
int _py; |
||||||
|
int _pfutx; |
||||||
|
int _pfuty; |
||||||
|
int _pdir; |
||||||
|
|
||||||
|
int _pRSpell; |
||||||
|
char _pRSplType; |
||||||
|
|
||||||
|
char _pSplLvl[64]; |
||||||
|
uint64_t _pMemSpells; |
||||||
|
uint64_t _pAblSpells; |
||||||
|
uint64_t _pScrlSpells; |
||||||
|
|
||||||
|
char _pName[32]; |
||||||
|
char _pClass; |
||||||
|
|
||||||
|
int _pStrength; |
||||||
|
int _pBaseStr; |
||||||
|
int _pMagic; |
||||||
|
int _pBaseMag; |
||||||
|
int _pDexterity; |
||||||
|
int _pBaseDex; |
||||||
|
int _pVitality; |
||||||
|
int _pBaseVit; |
||||||
|
|
||||||
|
int _pStatPts; |
||||||
|
|
||||||
|
int _pDamageMod; |
||||||
|
|
||||||
|
int _pHitPoints; |
||||||
|
int _pMaxHP; |
||||||
|
int _pMana; |
||||||
|
int _pMaxMana; |
||||||
|
char _pLevel; |
||||||
|
int _pExperience; |
||||||
|
|
||||||
|
char _pArmorClass; |
||||||
|
|
||||||
|
char _pMagResist; |
||||||
|
char _pFireResist; |
||||||
|
char _pLightResist; |
||||||
|
|
||||||
|
int _pGold; |
||||||
|
|
||||||
|
std::map<int, int> InvBody; |
||||||
|
int InvList[MAXINV]; |
||||||
|
int InvGrid[MAXINV]; |
||||||
|
std::map<int, int> SpdList; |
||||||
|
int HoldItem; |
||||||
|
|
||||||
|
int _pIMinDam; |
||||||
|
int _pIMaxDam; |
||||||
|
int _pIBonusDam; |
||||||
|
int _pIAC; |
||||||
|
int _pIBonusToHit; |
||||||
|
int _pIBonusAC; |
||||||
|
int _pIBonusDamMod; |
||||||
|
char _pISplLvlAdd; |
||||||
|
bool pManaShield; |
||||||
|
}; |
||||||
|
} // namespace DAPI
|
||||||
@ -0,0 +1,361 @@ |
|||||||
|
#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, |
||||||
|
SPELLPID, |
||||||
|
TSPELLID, |
||||||
|
TSPELLPID, |
||||||
|
RESURRECT, |
||||||
|
OPOBJT, |
||||||
|
KNOCKBACK, |
||||||
|
TALKXY, |
||||||
|
NEWLVL, |
||||||
|
WARP, |
||||||
|
CHEAT_EXPERIENCE, |
||||||
|
CHEAT_SPELL_LEVEL, |
||||||
|
DEBUG, |
||||||
|
SYNCDATA, |
||||||
|
MONSTDEATH, |
||||||
|
MONSTDAMAGE, |
||||||
|
PLRDEAD, |
||||||
|
REQUESTGITEM, |
||||||
|
REQUESTAGITEM, |
||||||
|
GOTOGETITEM, |
||||||
|
GOTOAGETITEM, |
||||||
|
OPENDOOR, |
||||||
|
CLOSEDOOR, |
||||||
|
OPERATEOBJ, |
||||||
|
PLROPOBJ, |
||||||
|
BREAKOBJ, |
||||||
|
CHANGEPLRITEMS, |
||||||
|
DELPLRITEMS, |
||||||
|
PLRDAMAGE, |
||||||
|
PLRLEVEL, |
||||||
|
DROPITEM, |
||||||
|
PLAYER_JOINLEVEL, |
||||||
|
SEND_PLRINFO, |
||||||
|
SATTACKXY, |
||||||
|
ACTIVATEPORTAL, |
||||||
|
DEACTIVATEPORTAL, |
||||||
|
DLEVEL_0, |
||||||
|
DLEVEL_1, |
||||||
|
DLEVEL_2, |
||||||
|
DLEVEL_3, |
||||||
|
DLEVEL_4, |
||||||
|
DLEVEL_5, |
||||||
|
DLEVEL_6, |
||||||
|
DLEVEL_7, |
||||||
|
DLEVEL_8, |
||||||
|
DLEVEL_9, |
||||||
|
DLEVEL_10, |
||||||
|
DLEVEL_11, |
||||||
|
DLEVEL_12, |
||||||
|
DLEVEL_13, |
||||||
|
DLEVEL_14, |
||||||
|
DLEVEL_15, |
||||||
|
DLEVEL_16, |
||||||
|
DLEVEL_JUNK, |
||||||
|
DLEVEL_END, |
||||||
|
HEALOTHER, |
||||||
|
STRING, |
||||||
|
SETSTR, |
||||||
|
SETMAG, |
||||||
|
SETDEX, |
||||||
|
SETVIT, |
||||||
|
RETOWN, |
||||||
|
SPELLXYD, |
||||||
|
ITEMEXTRA, |
||||||
|
SYNCPUTITEM, |
||||||
|
KILLGOLEM, |
||||||
|
SYNCQUEST, |
||||||
|
ENDSHIELD, |
||||||
|
AWAKEGOLEM, |
||||||
|
NOVA, |
||||||
|
SETSHIELD, |
||||||
|
REMSHIELD, |
||||||
|
FAKE_SETID, |
||||||
|
FAKE_DROPID, |
||||||
|
TOGGLECHARACTER, |
||||||
|
SETSPELL, |
||||||
|
TOGGLEINVENTORY, |
||||||
|
PUTINCURSOR, |
||||||
|
PUTCURSORITEM, |
||||||
|
IDENTIFYSTOREITEM, |
||||||
|
NUM_CMDS, |
||||||
|
}; |
||||||
|
|
||||||
|
enum struct EquipSlot { |
||||||
|
HEAD = 0, |
||||||
|
RIGHTRING = 1, |
||||||
|
LEFTRING = 2, |
||||||
|
AMULET = 3, |
||||||
|
LEFTHAND = 4, |
||||||
|
RIGHTHAND = 5, |
||||||
|
BODY = 6, |
||||||
|
INV1 = 7, |
||||||
|
INV2 = 8, |
||||||
|
INV3 = 9, |
||||||
|
INV4 = 10, |
||||||
|
INV5 = 11, |
||||||
|
INV6 = 12, |
||||||
|
INV7 = 13, |
||||||
|
INV8 = 14, |
||||||
|
INV9 = 15, |
||||||
|
INV10 = 16, |
||||||
|
INV11 = 17, |
||||||
|
INV12 = 18, |
||||||
|
INV13 = 19, |
||||||
|
INV14 = 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, |
||||||
|
STASH1 = 55, |
||||||
|
STASH2 = 56, |
||||||
|
STASH3 = 57, |
||||||
|
STASH4 = 58, |
||||||
|
STASH5 = 59, |
||||||
|
STASH6 = 60, |
||||||
|
STASH7 = 61, |
||||||
|
STASH8 = 62, |
||||||
|
STASH9 = 63, |
||||||
|
STASH10 = 64, |
||||||
|
STASH11 = 65, |
||||||
|
STASH12 = 66, |
||||||
|
STASH13 = 67, |
||||||
|
STASH14 = 68, |
||||||
|
STASH15 = 69, |
||||||
|
STASH16 = 70, |
||||||
|
STASH17 = 71, |
||||||
|
STASH18 = 72, |
||||||
|
STASH19 = 73, |
||||||
|
STASH20 = 74, |
||||||
|
STASH21 = 75, |
||||||
|
STASH22 = 76, |
||||||
|
STASH23 = 77, |
||||||
|
STASH24 = 78, |
||||||
|
STASH25 = 79, |
||||||
|
STASH26 = 80, |
||||||
|
STASH27 = 81, |
||||||
|
STASH28 = 82, |
||||||
|
STASH29 = 83, |
||||||
|
STASH30 = 84, |
||||||
|
STASH31 = 85, |
||||||
|
STASH32 = 86, |
||||||
|
STASH33 = 87, |
||||||
|
STASH34 = 88, |
||||||
|
STASH35 = 89, |
||||||
|
STASH36 = 90, |
||||||
|
STASH37 = 91, |
||||||
|
STASH38 = 92, |
||||||
|
STASH39 = 93, |
||||||
|
STASH40 = 94, |
||||||
|
STASH41 = 95, |
||||||
|
STASH42 = 96, |
||||||
|
STASH43 = 97, |
||||||
|
STASH44 = 98, |
||||||
|
STASH45 = 99, |
||||||
|
STASH46 = 100, |
||||||
|
STASH47 = 101, |
||||||
|
STASH48 = 102, |
||||||
|
STASH49 = 103, |
||||||
|
STASH50 = 104, |
||||||
|
STASH51 = 105, |
||||||
|
STASH52 = 106, |
||||||
|
STASH53 = 107, |
||||||
|
STASH54 = 108, |
||||||
|
STASH55 = 109, |
||||||
|
STASH56 = 110, |
||||||
|
STASH57 = 111, |
||||||
|
STASH58 = 112, |
||||||
|
STASH59 = 113, |
||||||
|
STASH60 = 114, |
||||||
|
STASH61 = 115, |
||||||
|
STASH62 = 116, |
||||||
|
STASH63 = 117, |
||||||
|
STASH64 = 118, |
||||||
|
STASH65 = 119, |
||||||
|
STASH66 = 120, |
||||||
|
STASH67 = 121, |
||||||
|
STASH68 = 122, |
||||||
|
STASH69 = 123, |
||||||
|
STASH70 = 124, |
||||||
|
STASH71 = 125, |
||||||
|
STASH72 = 126, |
||||||
|
STASH73 = 127, |
||||||
|
STASH74 = 128, |
||||||
|
STASH75 = 129, |
||||||
|
STASH76 = 130, |
||||||
|
STASH77 = 131, |
||||||
|
STASH78 = 132, |
||||||
|
STASH79 = 133, |
||||||
|
STASH80 = 134, |
||||||
|
STASH81 = 135, |
||||||
|
STASH82 = 136, |
||||||
|
STASH83 = 137, |
||||||
|
STASH84 = 138, |
||||||
|
STASH85 = 139, |
||||||
|
STASH86 = 140, |
||||||
|
STASH87 = 141, |
||||||
|
STASH88 = 142, |
||||||
|
STASH89 = 143, |
||||||
|
STASH90 = 144, |
||||||
|
STASH91 = 145, |
||||||
|
STASH92 = 146, |
||||||
|
STASH93 = 147, |
||||||
|
STASH94 = 148, |
||||||
|
STASH95 = 149, |
||||||
|
STASH96 = 150, |
||||||
|
STASH97 = 151, |
||||||
|
STASH98 = 152, |
||||||
|
STASH99 = 153, |
||||||
|
STASH100 = 154 |
||||||
|
}; |
||||||
|
|
||||||
|
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
|
||||||
@ -0,0 +1,14 @@ |
|||||||
|
#pragma once |
||||||
|
|
||||||
|
#include "../towners.h" |
||||||
|
|
||||||
|
namespace DAPI { |
||||||
|
|
||||||
|
struct TownerData { |
||||||
|
int ID; |
||||||
|
devilution::_talker_id _ttype; |
||||||
|
int _tx; |
||||||
|
int _ty; |
||||||
|
char _tName[32]; |
||||||
|
}; |
||||||
|
} // namespace DAPI
|
||||||
@ -0,0 +1,14 @@ |
|||||||
|
#pragma once |
||||||
|
#include "../levels/trigs.h" |
||||||
|
|
||||||
|
namespace DAPI { |
||||||
|
struct TriggerData { |
||||||
|
bool compare(devilution::TriggerStruct &other) { return (other._tlvl == lvl && other._tmsg == type && other.position.x == x && other.position.y == y); } |
||||||
|
|
||||||
|
int ID; |
||||||
|
int x; |
||||||
|
int y; |
||||||
|
int lvl; |
||||||
|
int type; |
||||||
|
}; |
||||||
|
} // namespace DAPI
|
||||||
Loading…
Reference in new issue