🎨 Format code
This commit is contained in:
parent
69f2452119
commit
5fdb9ce459
87 changed files with 345 additions and 323 deletions
|
|
@ -57,8 +57,8 @@ void LoadMaskedArt(const char *pszFile, Art *art, int frames, int mask)
|
|||
void LoadArt(Art *art, const BYTE *artData, int w, int h, int frames)
|
||||
{
|
||||
art->frames = frames;
|
||||
art->surface = ScaleSurfaceToOutput(SDLSurfaceUniquePtr{SDL_CreateRGBSurfaceWithFormatFrom(
|
||||
const_cast<BYTE *>(artData), w, h, 8, w, SDL_PIXELFORMAT_INDEX8)});
|
||||
art->surface = ScaleSurfaceToOutput(SDLSurfaceUniquePtr { SDL_CreateRGBSurfaceWithFormatFrom(
|
||||
const_cast<BYTE *>(artData), w, h, 8, w, SDL_PIXELFORMAT_INDEX8) });
|
||||
art->logical_width = w;
|
||||
art->frame_height = h / frames;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -629,7 +629,7 @@ static void UiSelHeroDialog(
|
|||
} while (selhero_navigateYesNo);
|
||||
|
||||
*dlgresult = selhero_result;
|
||||
strncpy(*name, selhero_heroInfo.name, sizeof(*name));
|
||||
strncpy(*name, selhero_heroInfo.name, sizeof(*name));
|
||||
}
|
||||
|
||||
void UiSelHeroSingDialog(
|
||||
|
|
|
|||
|
|
@ -17,8 +17,12 @@ namespace devilution {
|
|||
|
||||
#ifndef _DEBUG
|
||||
#define assert(exp)
|
||||
#define assurance(exp, value) if (!(exp)) return
|
||||
#define commitment(exp, value) if (!(exp)) return false
|
||||
#define assurance(exp, value) \
|
||||
if (!(exp)) \
|
||||
return
|
||||
#define commitment(exp, value) \
|
||||
if (!(exp)) \
|
||||
return false
|
||||
#else
|
||||
#define assert(exp) (void)((exp) || (assert_fail(__LINE__, __FILE__, #exp), 0))
|
||||
#define assurance(exp, value) (void)((exp) || (app_fatal("%s: %s was %i", __func__, #exp, value), 0))
|
||||
|
|
@ -35,4 +39,4 @@ void DrawDlg(const char *pszFmt, ...) DVL_PRINTF_ATTRIBUTE(1, 2);
|
|||
[[noreturn]] void InsertCDDlg();
|
||||
[[noreturn]] void DirErrorDlg(const char *error);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -84,4 +84,4 @@ void SetAutomapView(Sint32 x, Sint32 y);
|
|||
*/
|
||||
void AutomapZoomReset();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ int codec_decode(BYTE *pbSrcDst, DWORD size, const char *pszPassword);
|
|||
DWORD codec_get_encoded_len(DWORD dwSrcBytes);
|
||||
void codec_encode(BYTE *pbSrcDst, DWORD size, int size_64, const char *pszPassword);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -164,4 +164,4 @@ extern const BYTE gbFontTransTbl[256];
|
|||
|
||||
extern RECT32 ChrBtnsRect[4];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -1,4 +1,4 @@
|
|||
# Controls handling
|
||||
#Controls handling
|
||||
|
||||
DevilutionX supports mouse & keyboard and gamepad input.
|
||||
|
||||
|
|
|
|||
|
|
@ -167,7 +167,7 @@ void GameController::Add(int joystick_index)
|
|||
controllers_->push_back(result);
|
||||
|
||||
const SDL_JoystickGUID guid = SDL_JoystickGetGUID(sdl_joystick);
|
||||
SDLUniquePtr<char> mapping{SDL_GameControllerMappingForGUID(guid)};
|
||||
SDLUniquePtr<char> mapping { SDL_GameControllerMappingForGUID(guid) };
|
||||
SDL_Log("Opened game controller with mapping:\n%s", mapping.get());
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -57,4 +57,4 @@ void CheckCursMove();
|
|||
extern const int InvItemWidth[];
|
||||
extern const int InvItemHeight[];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -28,4 +28,4 @@ void InitDead();
|
|||
void AddDead(int dx, int dy, int8_t dv, direction ddir);
|
||||
void SetDead();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ void PrintDebugQuest();
|
|||
void GetDebugMonster();
|
||||
void NextDebugMonster();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -80,4 +80,4 @@ extern int debug_mode_key_j;
|
|||
#endif
|
||||
extern bool gbFriendlyMode;
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@ void doom_init();
|
|||
void doom_close();
|
||||
void doom_draw(CelOutputBuffer out);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -32,4 +32,4 @@ void drlg_l1_crypt_pattern5(int rndper);
|
|||
void drlg_l1_crypt_pattern6(int rndper);
|
||||
void drlg_l1_crypt_pattern7(int rndper);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -34,4 +34,4 @@ void LoadL2Dungeon(const char *sFileName, int vx, int vy);
|
|||
void LoadPreL2Dungeon(const char *sFileName, int vx, int vy);
|
||||
void CreateL2Dungeon(DWORD rseed, lvl_entry entry);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -1983,7 +1983,8 @@ static void DRLG_L3Wood()
|
|||
volatile // visual studio 2019 throws internal compiler error without it, see #708
|
||||
|
||||
#endif
|
||||
int i, j, x, y, xx, yy, rt, rp, x1, y1, x2, y2;
|
||||
int i,
|
||||
j, x, y, xx, yy, rt, rp, x1, y1, x2, y2;
|
||||
bool skip;
|
||||
|
||||
for (j = 1; j < DMAXY - 1; j++) { // BUGFIX: Change '0' to '1' (fixed)
|
||||
|
|
|
|||
|
|
@ -15,4 +15,4 @@ void CreateL3Dungeon(DWORD rseed, lvl_entry entry);
|
|||
void LoadL3Dungeon(const char *sFileName, int vx, int vy);
|
||||
void LoadPreL3Dungeon(const char *sFileName, int vx, int vy);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ bool IsDURWall(char d);
|
|||
bool IsDLLWall(char dd);
|
||||
void CreateL4Dungeon(DWORD rseed, lvl_entry entry);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -12,4 +12,4 @@ void dthread_send_delta(int pnum, char cmd, void *pbSrc, int dwLen);
|
|||
void dthread_start();
|
||||
void dthread_cleanup();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ void base::handle_accept(packet &pkt)
|
|||
connected_table[plr_self] = true;
|
||||
}
|
||||
if (game_init_info != pkt.info()) {
|
||||
if(pkt.info().size() != sizeof(GameData)) {
|
||||
if (pkt.info().size() != sizeof(GameData)) {
|
||||
ABORT();
|
||||
}
|
||||
// we joined and did not create
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
namespace devilution {
|
||||
namespace net {
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
class base_protocol : public base {
|
||||
public:
|
||||
virtual int create(std::string addrstr, std::string passwd);
|
||||
|
|
@ -49,17 +49,17 @@ private:
|
|||
void wait_join();
|
||||
};
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
plr_t base_protocol<P>::get_master()
|
||||
{
|
||||
plr_t ret = plr_self;
|
||||
for (plr_t i = 0; i < MAX_PLRS; ++i)
|
||||
if(peers[i])
|
||||
if (peers[i])
|
||||
ret = std::min(ret, i);
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
bool base_protocol<P>::wait_network()
|
||||
{
|
||||
// wait for ZeroTier for 5 seconds
|
||||
|
|
@ -71,14 +71,14 @@ bool base_protocol<P>::wait_network()
|
|||
return proto.network_online();
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
void base_protocol<P>::disconnect_net(plr_t plr)
|
||||
{
|
||||
proto.disconnect(peers[plr]);
|
||||
peers[plr] = endpoint();
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
bool base_protocol<P>::wait_firstpeer()
|
||||
{
|
||||
// wait for peer for 5 seconds
|
||||
|
|
@ -94,21 +94,21 @@ bool base_protocol<P>::wait_firstpeer()
|
|||
return (bool)firstpeer;
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
void base_protocol<P>::send_info_request()
|
||||
{
|
||||
auto pkt = pktfty->make_packet<PT_INFO_REQUEST>(PLR_BROADCAST,
|
||||
PLR_MASTER);
|
||||
PLR_MASTER);
|
||||
proto.send_oob_mc(pkt->data());
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
void base_protocol<P>::wait_join()
|
||||
{
|
||||
randombytes_buf(reinterpret_cast<unsigned char *>(&cookie_self),
|
||||
sizeof(cookie_t));
|
||||
sizeof(cookie_t));
|
||||
auto pkt = pktfty->make_packet<PT_JOIN_REQUEST>(PLR_BROADCAST,
|
||||
PLR_MASTER, cookie_self, game_init_info);
|
||||
PLR_MASTER, cookie_self, game_init_info);
|
||||
proto.send(firstpeer, pkt->data());
|
||||
for (auto i = 0; i < 500; ++i) {
|
||||
recv();
|
||||
|
|
@ -118,13 +118,13 @@ void base_protocol<P>::wait_join()
|
|||
}
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
int base_protocol<P>::create(std::string addrstr, std::string passwd)
|
||||
{
|
||||
setup_password(passwd);
|
||||
gamename = addrstr;
|
||||
|
||||
if(wait_network()) {
|
||||
if (wait_network()) {
|
||||
plr_self = 0;
|
||||
connected_table[plr_self] = true;
|
||||
}
|
||||
|
|
@ -132,44 +132,44 @@ int base_protocol<P>::create(std::string addrstr, std::string passwd)
|
|||
return (plr_self == PLR_BROADCAST ? MAX_PLRS : plr_self);
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
int base_protocol<P>::join(std::string addrstr, std::string passwd)
|
||||
{
|
||||
//addrstr = "fd80:56c2:e21c:0:199:931d:b14:c4d2";
|
||||
setup_password(passwd);
|
||||
gamename = addrstr;
|
||||
if(wait_network())
|
||||
if(wait_firstpeer())
|
||||
if (wait_network())
|
||||
if (wait_firstpeer())
|
||||
wait_join();
|
||||
return (plr_self == PLR_BROADCAST ? MAX_PLRS : plr_self);
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
void base_protocol<P>::poll()
|
||||
{
|
||||
recv();
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
void base_protocol<P>::send(packet &pkt)
|
||||
{
|
||||
if(pkt.dest() < MAX_PLRS) {
|
||||
if(pkt.dest() == myplr)
|
||||
if (pkt.dest() < MAX_PLRS) {
|
||||
if (pkt.dest() == myplr)
|
||||
return;
|
||||
if(peers[pkt.dest()])
|
||||
if (peers[pkt.dest()])
|
||||
proto.send(peers[pkt.dest()], pkt.data());
|
||||
} else if(pkt.dest() == PLR_BROADCAST) {
|
||||
} else if (pkt.dest() == PLR_BROADCAST) {
|
||||
for (auto &peer : peers)
|
||||
if(peer)
|
||||
if (peer)
|
||||
proto.send(peer, pkt.data());
|
||||
} else if(pkt.dest() == PLR_MASTER) {
|
||||
} else if (pkt.dest() == PLR_MASTER) {
|
||||
throw dvlnet_exception();
|
||||
} else {
|
||||
throw dvlnet_exception();
|
||||
}
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
void base_protocol<P>::recv()
|
||||
{
|
||||
try {
|
||||
|
|
@ -191,7 +191,7 @@ void base_protocol<P>::recv()
|
|||
}
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
void base_protocol<P>::handle_join_request(packet &pkt, endpoint sender)
|
||||
{
|
||||
plr_t i;
|
||||
|
|
@ -201,7 +201,7 @@ void base_protocol<P>::handle_join_request(packet &pkt, endpoint sender)
|
|||
break;
|
||||
}
|
||||
}
|
||||
if(i >= MAX_PLRS) {
|
||||
if (i >= MAX_PLRS) {
|
||||
//already full
|
||||
return;
|
||||
}
|
||||
|
|
@ -218,7 +218,7 @@ void base_protocol<P>::handle_join_request(packet &pkt, endpoint sender)
|
|||
proto.send(sender, reply->data());
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
void base_protocol<P>::recv_decrypted(packet &pkt, endpoint sender)
|
||||
{
|
||||
if (pkt.src() == PLR_BROADCAST && pkt.dest() == PLR_MASTER && pkt.type() == PT_INFO_REPLY) {
|
||||
|
|
@ -231,20 +231,20 @@ void base_protocol<P>::recv_decrypted(packet &pkt, endpoint sender)
|
|||
recv_ingame(pkt, sender);
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
void base_protocol<P>::recv_ingame(packet &pkt, endpoint sender)
|
||||
{
|
||||
if (pkt.src() == PLR_BROADCAST && pkt.dest() == PLR_MASTER) {
|
||||
if(pkt.type() == PT_JOIN_REQUEST) {
|
||||
if (pkt.type() == PT_JOIN_REQUEST) {
|
||||
handle_join_request(pkt, sender);
|
||||
} else if(pkt.type() == PT_INFO_REQUEST) {
|
||||
if((plr_self != PLR_BROADCAST) && (get_master() == plr_self)) {
|
||||
} else if (pkt.type() == PT_INFO_REQUEST) {
|
||||
if ((plr_self != PLR_BROADCAST) && (get_master() == plr_self)) {
|
||||
buffer_t buf;
|
||||
buf.resize(gamename.size());
|
||||
std::memcpy(buf.data(), &gamename[0], gamename.size());
|
||||
auto reply = pktfty->make_packet<PT_INFO_REPLY>(PLR_BROADCAST,
|
||||
PLR_MASTER,
|
||||
buf);
|
||||
PLR_MASTER,
|
||||
buf);
|
||||
proto.send_oob(sender, reply->data());
|
||||
}
|
||||
}
|
||||
|
|
@ -265,18 +265,18 @@ void base_protocol<P>::recv_ingame(packet &pkt, endpoint sender)
|
|||
recv_local(pkt);
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
std::vector<std::string> base_protocol<P>::get_gamelist()
|
||||
{
|
||||
recv();
|
||||
std::vector<std::string> ret;
|
||||
for (auto& s : game_list) {
|
||||
for (auto &s : game_list) {
|
||||
ret.push_back(s.first);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
bool base_protocol<P>::SNetLeaveGame(int type)
|
||||
{
|
||||
auto ret = base::SNetLeaveGame(type);
|
||||
|
|
@ -284,7 +284,7 @@ bool base_protocol<P>::SNetLeaveGame(int type)
|
|||
return ret;
|
||||
}
|
||||
|
||||
template<class P>
|
||||
template <class P>
|
||||
std::string base_protocol<P>::make_default_gamename()
|
||||
{
|
||||
return proto.make_default_gamename();
|
||||
|
|
|
|||
|
|
@ -161,7 +161,7 @@ bool cdwrap<T>::SNetGetTurnsInTransit(DWORD *turns)
|
|||
template <class T>
|
||||
std::string cdwrap<T>::make_default_gamename()
|
||||
{
|
||||
return dvlnet_wrap->make_default_gamename();
|
||||
return dvlnet_wrap->make_default_gamename();
|
||||
}
|
||||
|
||||
} // namespace net
|
||||
|
|
|
|||
|
|
@ -36,45 +36,46 @@ void protocol_zt::set_nonblock(int fd)
|
|||
void protocol_zt::set_nodelay(int fd)
|
||||
{
|
||||
const int yes = 1;
|
||||
lwip_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void*)&yes, sizeof(yes));
|
||||
lwip_setsockopt(fd, IPPROTO_TCP, TCP_NODELAY, (void *)&yes, sizeof(yes));
|
||||
}
|
||||
|
||||
void protocol_zt::set_reuseaddr(int fd)
|
||||
{
|
||||
const int yes = 1;
|
||||
lwip_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void*)&yes, sizeof(yes));
|
||||
lwip_setsockopt(fd, SOL_SOCKET, SO_REUSEADDR, (void *)&yes, sizeof(yes));
|
||||
}
|
||||
|
||||
bool protocol_zt::network_online()
|
||||
{
|
||||
if(!zerotier_network_ready())
|
||||
if (!zerotier_network_ready())
|
||||
return false;
|
||||
|
||||
struct sockaddr_in6 in6{};
|
||||
struct sockaddr_in6 in6 {
|
||||
};
|
||||
in6.sin6_port = htons(default_port);
|
||||
in6.sin6_family = AF_INET6;
|
||||
in6.sin6_addr = in6addr_any;
|
||||
|
||||
if(fd_udp == -1) {
|
||||
if (fd_udp == -1) {
|
||||
fd_udp = lwip_socket(AF_INET6, SOCK_DGRAM, 0);
|
||||
set_reuseaddr(fd_udp);
|
||||
auto ret = lwip_bind(fd_udp, (struct sockaddr *)&in6, sizeof(in6));
|
||||
if(ret < 0) {
|
||||
if (ret < 0) {
|
||||
SDL_Log("lwip, (udp) bind: %s\n", strerror(errno));
|
||||
throw protocol_exception();
|
||||
}
|
||||
set_nonblock(fd_udp);
|
||||
}
|
||||
if(fd_tcp == -1) {
|
||||
if (fd_tcp == -1) {
|
||||
fd_tcp = lwip_socket(AF_INET6, SOCK_STREAM, 0);
|
||||
set_reuseaddr(fd_tcp);
|
||||
auto r1 = lwip_bind(fd_tcp, (struct sockaddr *)&in6, sizeof(in6));
|
||||
if(r1 < 0) {
|
||||
if (r1 < 0) {
|
||||
SDL_Log("lwip, (tcp) bind: %s\n", strerror(errno));
|
||||
throw protocol_exception();
|
||||
}
|
||||
auto r2 = lwip_listen(fd_tcp, 10);
|
||||
if(r2 < 0) {
|
||||
if (r2 < 0) {
|
||||
SDL_Log("lwip, listen: %s\n", strerror(errno));
|
||||
throw protocol_exception();
|
||||
}
|
||||
|
|
@ -84,15 +85,16 @@ bool protocol_zt::network_online()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool protocol_zt::send(const endpoint& peer, const buffer_t& data)
|
||||
bool protocol_zt::send(const endpoint &peer, const buffer_t &data)
|
||||
{
|
||||
peer_list[peer].send_queue.push_back(frame_queue::make_frame(data));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool protocol_zt::send_oob(const endpoint& peer, const buffer_t& data)
|
||||
bool protocol_zt::send_oob(const endpoint &peer, const buffer_t &data)
|
||||
{
|
||||
struct sockaddr_in6 in6{};
|
||||
struct sockaddr_in6 in6 {
|
||||
};
|
||||
in6.sin6_port = htons(default_port);
|
||||
in6.sin6_family = AF_INET6;
|
||||
std::copy(peer.addr.begin(), peer.addr.end(), in6.sin6_addr.s6_addr);
|
||||
|
|
@ -100,35 +102,36 @@ bool protocol_zt::send_oob(const endpoint& peer, const buffer_t& data)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool protocol_zt::send_oob_mc(const buffer_t& data)
|
||||
bool protocol_zt::send_oob_mc(const buffer_t &data)
|
||||
{
|
||||
endpoint mc;
|
||||
std::copy(dvl_multicast_addr, dvl_multicast_addr+16, mc.addr.begin());
|
||||
std::copy(dvl_multicast_addr, dvl_multicast_addr + 16, mc.addr.begin());
|
||||
return send_oob(mc, data);
|
||||
}
|
||||
|
||||
bool protocol_zt::send_queued_peer(const endpoint& peer)
|
||||
bool protocol_zt::send_queued_peer(const endpoint &peer)
|
||||
{
|
||||
if(peer_list[peer].fd == -1) {
|
||||
if (peer_list[peer].fd == -1) {
|
||||
peer_list[peer].fd = lwip_socket(AF_INET6, SOCK_STREAM, 0);
|
||||
set_nodelay(peer_list[peer].fd);
|
||||
set_nonblock(peer_list[peer].fd);
|
||||
struct sockaddr_in6 in6{};
|
||||
struct sockaddr_in6 in6 {
|
||||
};
|
||||
in6.sin6_port = htons(default_port);
|
||||
in6.sin6_family = AF_INET6;
|
||||
std::copy(peer.addr.begin(), peer.addr.end(), in6.sin6_addr.s6_addr);
|
||||
lwip_connect(peer_list[peer].fd, (const struct sockaddr *)&in6, sizeof(in6));
|
||||
}
|
||||
while(!peer_list[peer].send_queue.empty()) {
|
||||
while (!peer_list[peer].send_queue.empty()) {
|
||||
auto len = peer_list[peer].send_queue.front().size();
|
||||
auto r = lwip_send(peer_list[peer].fd, peer_list[peer].send_queue.front().data(), len, 0);
|
||||
if(r < 0) {
|
||||
if (r < 0) {
|
||||
// handle error
|
||||
return false;
|
||||
} else if (decltype(len)(r) < len) {
|
||||
// partial send
|
||||
auto it = peer_list[peer].send_queue.front().begin();
|
||||
peer_list[peer].send_queue.front().erase(it, it+r);
|
||||
peer_list[peer].send_queue.front().erase(it, it + r);
|
||||
return true;
|
||||
} else if (decltype(len)(r) == len) {
|
||||
peer_list[peer].send_queue.pop_front();
|
||||
|
|
@ -139,15 +142,15 @@ bool protocol_zt::send_queued_peer(const endpoint& peer)
|
|||
return true;
|
||||
}
|
||||
|
||||
bool protocol_zt::recv_peer(const endpoint& peer)
|
||||
bool protocol_zt::recv_peer(const endpoint &peer)
|
||||
{
|
||||
unsigned char buf[PKTBUF_LEN];
|
||||
while(true) {
|
||||
while (true) {
|
||||
auto len = lwip_recv(peer_list[peer].fd, buf, sizeof(buf), 0);
|
||||
if(len >= 0) {
|
||||
peer_list[peer].recv_queue.write(buffer_t(buf, buf+len));
|
||||
if (len >= 0) {
|
||||
peer_list[peer].recv_queue.write(buffer_t(buf, buf + len));
|
||||
} else {
|
||||
if(errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
if (errno == EAGAIN || errno == EWOULDBLOCK) {
|
||||
return true;
|
||||
} else {
|
||||
return false;
|
||||
|
|
@ -158,8 +161,8 @@ bool protocol_zt::recv_peer(const endpoint& peer)
|
|||
|
||||
bool protocol_zt::send_queued_all()
|
||||
{
|
||||
for(auto& peer : peer_list) {
|
||||
if(!send_queued_peer(peer.first)) {
|
||||
for (auto &peer : peer_list) {
|
||||
if (!send_queued_peer(peer.first)) {
|
||||
// disconnect this peer
|
||||
}
|
||||
}
|
||||
|
|
@ -168,9 +171,9 @@ bool protocol_zt::send_queued_all()
|
|||
|
||||
bool protocol_zt::recv_from_peers()
|
||||
{
|
||||
for(auto& peer : peer_list) {
|
||||
if(peer.second.fd != -1) {
|
||||
if(!recv_peer(peer.first)) {
|
||||
for (auto &peer : peer_list) {
|
||||
if (peer.second.fd != -1) {
|
||||
if (!recv_peer(peer.first)) {
|
||||
// error, disconnect?
|
||||
}
|
||||
}
|
||||
|
|
@ -181,29 +184,31 @@ bool protocol_zt::recv_from_peers()
|
|||
bool protocol_zt::recv_from_udp()
|
||||
{
|
||||
unsigned char buf[PKTBUF_LEN];
|
||||
struct sockaddr_in6 in6{};
|
||||
struct sockaddr_in6 in6 {
|
||||
};
|
||||
socklen_t addrlen = sizeof(in6);
|
||||
auto len = lwip_recvfrom(fd_udp, buf, sizeof(buf), 0, (struct sockaddr *)&in6, &addrlen);
|
||||
if(len < 0)
|
||||
if (len < 0)
|
||||
return false;
|
||||
buffer_t data(buf, buf+len);
|
||||
buffer_t data(buf, buf + len);
|
||||
endpoint ep;
|
||||
std::copy(in6.sin6_addr.s6_addr, in6.sin6_addr.s6_addr+16, ep.addr.begin());
|
||||
std::copy(in6.sin6_addr.s6_addr, in6.sin6_addr.s6_addr + 16, ep.addr.begin());
|
||||
oob_recv_queue.push_back(std::make_pair(std::move(ep), std::move(data)));
|
||||
return true;
|
||||
}
|
||||
|
||||
bool protocol_zt::accept_all()
|
||||
{
|
||||
struct sockaddr_in6 in6{};
|
||||
struct sockaddr_in6 in6 {
|
||||
};
|
||||
socklen_t addrlen = sizeof(in6);
|
||||
while(true) {
|
||||
while (true) {
|
||||
auto newfd = lwip_accept(fd_tcp, (struct sockaddr *)&in6, &addrlen);
|
||||
if(newfd < 0)
|
||||
if (newfd < 0)
|
||||
break;
|
||||
endpoint ep;
|
||||
std::copy(in6.sin6_addr.s6_addr, in6.sin6_addr.s6_addr+16, ep.addr.begin());
|
||||
if(peer_list[ep].fd != -1) {
|
||||
std::copy(in6.sin6_addr.s6_addr, in6.sin6_addr.s6_addr + 16, ep.addr.begin());
|
||||
if (peer_list[ep].fd != -1) {
|
||||
SDL_Log("protocol_zt::accept_all: WARNING: overwriting connection\n");
|
||||
lwip_close(peer_list[ep].fd);
|
||||
}
|
||||
|
|
@ -214,22 +219,22 @@ bool protocol_zt::accept_all()
|
|||
return true;
|
||||
}
|
||||
|
||||
bool protocol_zt::recv(endpoint& peer, buffer_t& data)
|
||||
bool protocol_zt::recv(endpoint &peer, buffer_t &data)
|
||||
{
|
||||
accept_all();
|
||||
send_queued_all();
|
||||
recv_from_peers();
|
||||
recv_from_udp();
|
||||
|
||||
if(!oob_recv_queue.empty()) {
|
||||
if (!oob_recv_queue.empty()) {
|
||||
peer = oob_recv_queue.front().first;
|
||||
data = oob_recv_queue.front().second;
|
||||
oob_recv_queue.pop_front();
|
||||
return true;
|
||||
}
|
||||
|
||||
for(auto& p : peer_list) {
|
||||
if(p.second.recv_queue.packet_ready()) {
|
||||
for (auto &p : peer_list) {
|
||||
if (p.second.recv_queue.packet_ready()) {
|
||||
peer = p.first;
|
||||
data = p.second.recv_queue.read_packet();
|
||||
return true;
|
||||
|
|
@ -238,11 +243,11 @@ bool protocol_zt::recv(endpoint& peer, buffer_t& data)
|
|||
return false;
|
||||
}
|
||||
|
||||
void protocol_zt::disconnect(const endpoint& peer)
|
||||
void protocol_zt::disconnect(const endpoint &peer)
|
||||
{
|
||||
if(peer_list.count(peer)) {
|
||||
if(peer_list[peer].fd != -1) {
|
||||
if(lwip_close(peer_list[peer].fd) < 0) {
|
||||
if (peer_list.count(peer)) {
|
||||
if (peer_list[peer].fd != -1) {
|
||||
if (lwip_close(peer_list[peer].fd) < 0) {
|
||||
SDL_Log("lwip_close: %s\n", strerror(errno));
|
||||
}
|
||||
}
|
||||
|
|
@ -252,16 +257,16 @@ void protocol_zt::disconnect(const endpoint& peer)
|
|||
|
||||
void protocol_zt::close_all()
|
||||
{
|
||||
if(fd_tcp != -1) {
|
||||
if (fd_tcp != -1) {
|
||||
lwip_close(fd_tcp);
|
||||
fd_tcp = -1;
|
||||
}
|
||||
if(fd_udp != -1) {
|
||||
if (fd_udp != -1) {
|
||||
lwip_close(fd_udp);
|
||||
fd_udp = -1;
|
||||
}
|
||||
for(auto& i : peer_list) {
|
||||
if(i.second.fd != -1)
|
||||
for (auto &i : peer_list) {
|
||||
if (i.second.fd != -1)
|
||||
lwip_close(i.second.fd);
|
||||
}
|
||||
peer_list.clear();
|
||||
|
|
@ -272,15 +277,15 @@ protocol_zt::~protocol_zt()
|
|||
close_all();
|
||||
}
|
||||
|
||||
void protocol_zt::endpoint::from_string(const std::string& str)
|
||||
void protocol_zt::endpoint::from_string(const std::string &str)
|
||||
{
|
||||
ip_addr_t a;
|
||||
if(!ipaddr_aton(str.c_str(), &a))
|
||||
if (!ipaddr_aton(str.c_str(), &a))
|
||||
return;
|
||||
if(!IP_IS_V6_VAL(a))
|
||||
if (!IP_IS_V6_VAL(a))
|
||||
return;
|
||||
const unsigned char* r = reinterpret_cast<const unsigned char*>(a.u_addr.ip6.addr);
|
||||
std::copy(r, r+16, addr.begin());
|
||||
const unsigned char *r = reinterpret_cast<const unsigned char *>(a.u_addr.ip6.addr);
|
||||
std::copy(r, r + 16, addr.begin());
|
||||
}
|
||||
|
||||
uint64_t protocol_zt::current_ms()
|
||||
|
|
@ -294,9 +299,9 @@ std::string protocol_zt::make_default_gamename()
|
|||
std::string allowed_chars = "abcdefghkopqrstuvwxyz";
|
||||
std::random_device rd;
|
||||
std::uniform_int_distribution<int> dist(0, allowed_chars.size() - 1);
|
||||
for(int i = 0; i < 5; ++i) {
|
||||
for (int i = 0; i < 5; ++i) {
|
||||
ret += allowed_chars.at(dist(rd));
|
||||
}
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -15,7 +15,7 @@ namespace devilution {
|
|||
namespace net {
|
||||
|
||||
class protocol_exception : public std::exception {
|
||||
public:
|
||||
public:
|
||||
const char *what() const throw() override
|
||||
{
|
||||
return "Protocol error";
|
||||
|
|
@ -30,11 +30,11 @@ public:
|
|||
|
||||
explicit operator bool() const
|
||||
{
|
||||
auto empty = std::array<unsigned char, 16>{};
|
||||
auto empty = std::array<unsigned char, 16> {};
|
||||
return (addr != empty);
|
||||
}
|
||||
|
||||
bool operator<(const endpoint& rhs) const
|
||||
bool operator<(const endpoint &rhs) const
|
||||
{
|
||||
return addr < rhs.addr;
|
||||
}
|
||||
|
|
@ -44,23 +44,23 @@ public:
|
|||
return buffer_t(addr.begin(), addr.end());
|
||||
}
|
||||
|
||||
void unserialize(const buffer_t& buf)
|
||||
void unserialize(const buffer_t &buf)
|
||||
{
|
||||
if(buf.size() != 16)
|
||||
if (buf.size() != 16)
|
||||
throw protocol_exception();
|
||||
std::copy(buf.begin(), buf.end(), addr.begin());
|
||||
}
|
||||
|
||||
void from_string(const std::string& str);
|
||||
void from_string(const std::string &str);
|
||||
};
|
||||
|
||||
protocol_zt();
|
||||
~protocol_zt();
|
||||
void disconnect(const endpoint& peer);
|
||||
bool send(const endpoint& peer, const buffer_t& data);
|
||||
bool send_oob(const endpoint& peer, const buffer_t& data);
|
||||
bool send_oob_mc(const buffer_t& data);
|
||||
bool recv(endpoint& peer, buffer_t& data);
|
||||
void disconnect(const endpoint &peer);
|
||||
bool send(const endpoint &peer, const buffer_t &data);
|
||||
bool send_oob(const endpoint &peer, const buffer_t &data);
|
||||
bool send_oob_mc(const buffer_t &data);
|
||||
bool recv(endpoint &peer, buffer_t &data);
|
||||
bool network_online();
|
||||
std::string make_default_gamename();
|
||||
|
||||
|
|
@ -87,8 +87,8 @@ private:
|
|||
void set_nodelay(int fd);
|
||||
void set_reuseaddr(int fd);
|
||||
|
||||
bool send_queued_peer(const endpoint& peer);
|
||||
bool recv_peer(const endpoint& peer);
|
||||
bool send_queued_peer(const endpoint &peer);
|
||||
bool recv_peer(const endpoint &peer);
|
||||
bool send_queued_all();
|
||||
bool recv_from_peers();
|
||||
bool recv_from_udp();
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@ public:
|
|||
virtual ~tcp_client();
|
||||
|
||||
virtual std::string make_default_gamename();
|
||||
|
||||
private:
|
||||
frame_queue recv_queue;
|
||||
buffer_t recv_buffer = buffer_t(frame_queue::max_frame_size);
|
||||
|
|
|
|||
|
|
@ -18,10 +18,10 @@
|
|||
namespace devilution {
|
||||
namespace net {
|
||||
|
||||
void print_ip6_addr(void* x)
|
||||
void print_ip6_addr(void *x)
|
||||
{
|
||||
char ipstr[INET6_ADDRSTRLEN];
|
||||
struct sockaddr_in6 *in = (struct sockaddr_in6*)x;
|
||||
struct sockaddr_in6 *in = (struct sockaddr_in6 *)x;
|
||||
lwip_inet_ntop(AF_INET6, &(in->sin6_addr), ipstr, INET6_ADDRSTRLEN);
|
||||
SDL_Log("ZeroTier: ZTS_EVENT_ADDR_NEW_IP6, addr=%s\n", ipstr);
|
||||
}
|
||||
|
|
@ -36,5 +36,5 @@ void zt_ip6setup()
|
|||
UNLOCK_TCPIP_CORE();
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace net
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -1,8 +1,8 @@
|
|||
namespace devilution {
|
||||
namespace net {
|
||||
|
||||
void print_ip6_addr(void* x);
|
||||
void print_ip6_addr(void *x);
|
||||
void zt_ip6setup();
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace net
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -30,21 +30,21 @@ static std::atomic_bool zt_joined(false);
|
|||
static void callback(struct zts_callback_msg *msg)
|
||||
{
|
||||
//printf("callback %i\n", msg->eventCode);
|
||||
if(msg->eventCode == ZTS_EVENT_NODE_ONLINE) {
|
||||
if (msg->eventCode == ZTS_EVENT_NODE_ONLINE) {
|
||||
SDL_Log("ZeroTier: ZTS_EVENT_NODE_ONLINE, nodeId=%llx\n", (unsigned long long)msg->node->address);
|
||||
zt_node_online = true;
|
||||
if(!zt_joined) {
|
||||
if (!zt_joined) {
|
||||
zts_join(zt_network);
|
||||
zt_joined = true;
|
||||
}
|
||||
} else if(msg->eventCode == ZTS_EVENT_NODE_OFFLINE) {
|
||||
} else if (msg->eventCode == ZTS_EVENT_NODE_OFFLINE) {
|
||||
SDL_Log("ZeroTier: ZTS_EVENT_NODE_OFFLINE\n");
|
||||
zt_node_online = false;
|
||||
} else if(msg->eventCode == ZTS_EVENT_NETWORK_READY_IP6) {
|
||||
} else if (msg->eventCode == ZTS_EVENT_NETWORK_READY_IP6) {
|
||||
SDL_Log("ZeroTier: ZTS_EVENT_NETWORK_READY_IP6, networkId=%llx\n", (unsigned long long)msg->network->nwid);
|
||||
zt_ip6setup();
|
||||
zt_network_ready = true;
|
||||
} else if(msg->eventCode == ZTS_EVENT_ADDR_ADDED_IP6) {
|
||||
} else if (msg->eventCode == ZTS_EVENT_ADDR_ADDED_IP6) {
|
||||
print_ip6_addr(&(msg->addr->addr));
|
||||
}
|
||||
}
|
||||
|
|
@ -61,11 +61,11 @@ void zerotier_network_stop()
|
|||
|
||||
void zerotier_network_start()
|
||||
{
|
||||
if(zt_started)
|
||||
if (zt_started)
|
||||
return;
|
||||
zts_start(GetPrefPath().c_str(), (void(*)(void*))callback, 0);
|
||||
zts_start(GetPrefPath().c_str(), (void (*)(void *))callback, 0);
|
||||
std::atexit(zerotier_network_stop);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace net
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -9,9 +9,10 @@ void zerotier_network_stop();
|
|||
|
||||
// NOTE: We have patched our libzt to have the corresponding multicast
|
||||
// MAC hardcoded, since libzt is still missing the proper handling.
|
||||
const unsigned char dvl_multicast_addr[16] =
|
||||
{0xff, 0x0e, 0xa8, 0xa9, 0xb6, 0x11, 0x58, 0xce,
|
||||
0x04, 0x12, 0xfd, 0x73, 0x37, 0x86, 0x6f, 0xb7};
|
||||
const unsigned char dvl_multicast_addr[16] = {
|
||||
0xff, 0x0e, 0xa8, 0xa9, 0xb6, 0x11, 0x58, 0xce,
|
||||
0x04, 0x12, 0xfd, 0x73, 0x37, 0x86, 0x6f, 0xb7
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
} // namespace net
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ void Blit(SDL_Surface *src, SDL_Rect *src_rect, SDL_Rect *dst_rect);
|
|||
void RenderPresent();
|
||||
void PaletteGetEntries(DWORD dwNumEntries, SDL_Color *lpEntries);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -1081,4 +1081,4 @@ void ui_sound_init();
|
|||
void effects_play_sound(const char *snd_file);
|
||||
int GetSFXLength(int nSFX);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -26,4 +26,4 @@ void InitHash();
|
|||
DWORD PkwareCompress(BYTE *srcData, DWORD size);
|
||||
void PkwareDecompress(BYTE *pbInBuff, int recv_size, int dwMaxBytes);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -55,4 +55,4 @@ typename enum_values<T>::Iterator end(enum_values<T>)
|
|||
return typename enum_values<T>::Iterator(static_cast<typename std::underlying_type<T>::type>(T::LAST) + 1);
|
||||
}
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -76,4 +76,4 @@ void InitDiabloMsg(diablo_message e);
|
|||
void ClrDiabloMsg();
|
||||
void DrawDiabloMsg(CelOutputBuffer out);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -184,4 +184,4 @@ void DRLG_HoldThemeRooms();
|
|||
bool SkipThemeRoom(int x, int y);
|
||||
void InitLevels();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -34,4 +34,4 @@ void gmenu_slider_set(TMenuItem *pItem, int min, int max, int gamma);
|
|||
int gmenu_slider_get(TMenuItem *pItem, int min, int max);
|
||||
void gmenu_slider_steps(TMenuItem *pItem, int dwTicks);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -17,4 +17,4 @@ void DisplayHelp();
|
|||
void HelpScrollUp();
|
||||
void HelpScrollDown();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -38,4 +38,4 @@ WNDPROC SetWindowProc(WNDPROC NewProc);
|
|||
extern char gszVersionNumber[64];
|
||||
extern char gszProductName[64];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -46,4 +46,4 @@ void interface_msg_pump();
|
|||
bool IncProgress();
|
||||
void ShowProgress(interface_mode uMsg);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -764,7 +764,6 @@ bool AutoPlaceItemInInventorySlot(int playerNumber, int slotIndex, const ItemStr
|
|||
return done;
|
||||
}
|
||||
|
||||
|
||||
bool GoldAutoPlace(int pnum)
|
||||
{
|
||||
bool done = false;
|
||||
|
|
|
|||
|
|
@ -599,4 +599,4 @@ extern const PLStruct PL_Prefix[];
|
|||
extern const PLStruct PL_Suffix[];
|
||||
extern const UItemStruct UniqueItemList[];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -2619,7 +2619,7 @@ void SpawnItem(int m, int x, int y, bool sendmsg)
|
|||
if (monster[m]._uniqtype || ((monster[m].MData->mTreasure & 0x8000) && gbIsMultiplayer)) {
|
||||
idx = RndUItem(m);
|
||||
if (idx < 0) {
|
||||
SpawnUnique((_unique_items)-(idx + 1), x, y);
|
||||
SpawnUnique((_unique_items) - (idx + 1), x, y);
|
||||
return;
|
||||
}
|
||||
onlygood = true;
|
||||
|
|
@ -2631,7 +2631,7 @@ void SpawnItem(int m, int x, int y, bool sendmsg)
|
|||
idx--;
|
||||
onlygood = false;
|
||||
} else {
|
||||
SpawnUnique((_unique_items)-(idx + 1), x, y);
|
||||
SpawnUnique((_unique_items) - (idx + 1), x, y);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
|
@ -4497,11 +4497,11 @@ static void SpawnOnePremium(int i, int plvl, int myplr)
|
|||
case ITYPE_MARMOR:
|
||||
case ITYPE_HARMOR: {
|
||||
const auto mostValuablePlayerArmor = plr[myplr].GetMostValuableItem(
|
||||
[](const ItemStruct &item) {
|
||||
return item._itype == ITYPE_LARMOR
|
||||
|| item._itype == ITYPE_MARMOR
|
||||
|| item._itype == ITYPE_HARMOR;
|
||||
});
|
||||
[](const ItemStruct &item) {
|
||||
return item._itype == ITYPE_LARMOR
|
||||
|| item._itype == ITYPE_MARMOR
|
||||
|| item._itype == ITYPE_HARMOR;
|
||||
});
|
||||
|
||||
ivalue = mostValuablePlayerArmor == nullptr ? 0 : mostValuablePlayerArmor->_iIvalue;
|
||||
break;
|
||||
|
|
@ -4516,7 +4516,7 @@ static void SpawnOnePremium(int i, int plvl, int myplr)
|
|||
case ITYPE_RING:
|
||||
case ITYPE_AMULET: {
|
||||
const auto mostValuablePlayerItem = plr[myplr].GetMostValuableItem(
|
||||
[](const ItemStruct &item) { return item._itype == items[0]._itype; });
|
||||
[](const ItemStruct &item) { return item._itype == items[0]._itype; });
|
||||
|
||||
ivalue = mostValuablePlayerItem == nullptr ? 0 : mostValuablePlayerItem->_iIvalue;
|
||||
break;
|
||||
|
|
@ -4528,12 +4528,14 @@ static void SpawnOnePremium(int i, int plvl, int myplr)
|
|||
ivalue *= 0.8;
|
||||
|
||||
count++;
|
||||
} while (keepgoing || ((items[0]._iIvalue > 200000
|
||||
|| items[0]._iMinStr > strength
|
||||
|| items[0]._iMinMag > magic
|
||||
|| items[0]._iMinDex > dexterity
|
||||
|| items[0]._iIvalue < ivalue)
|
||||
&& count < 150));
|
||||
} while (keepgoing
|
||||
|| ((
|
||||
items[0]._iIvalue > 200000
|
||||
|| items[0]._iMinStr > strength
|
||||
|| items[0]._iMinMag > magic
|
||||
|| items[0]._iMinDex > dexterity
|
||||
|| items[0]._iIvalue < ivalue))
|
||||
&& count < 150);
|
||||
premiumitem[i] = items[0];
|
||||
premiumitem[i]._iCreateInfo = plvl | CF_SMITHPREMIUM;
|
||||
premiumitem[i]._iIdentified = true;
|
||||
|
|
@ -4819,11 +4821,11 @@ void SpawnBoy(int lvl)
|
|||
case ITYPE_MARMOR:
|
||||
case ITYPE_HARMOR: {
|
||||
const auto mostValuablePlayerArmor = plr[myplr].GetMostValuableItem(
|
||||
[](const ItemStruct &item) {
|
||||
return item._itype == ITYPE_LARMOR
|
||||
|| item._itype == ITYPE_MARMOR
|
||||
|| item._itype == ITYPE_HARMOR;
|
||||
});
|
||||
[](const ItemStruct &item) {
|
||||
return item._itype == ITYPE_LARMOR
|
||||
|| item._itype == ITYPE_MARMOR
|
||||
|| item._itype == ITYPE_HARMOR;
|
||||
});
|
||||
|
||||
ivalue = mostValuablePlayerArmor == nullptr ? 0 : mostValuablePlayerArmor->_iIvalue;
|
||||
break;
|
||||
|
|
@ -4838,7 +4840,7 @@ void SpawnBoy(int lvl)
|
|||
case ITYPE_RING:
|
||||
case ITYPE_AMULET: {
|
||||
const auto mostValuablePlayerItem = plr[myplr].GetMostValuableItem(
|
||||
[itemType](const ItemStruct &item) { return item._itype == itemType; });
|
||||
[itemType](const ItemStruct &item) { return item._itype == itemType; });
|
||||
|
||||
ivalue = mostValuablePlayerItem == nullptr ? 0 : mostValuablePlayerItem->_iIvalue;
|
||||
break;
|
||||
|
|
@ -4876,12 +4878,14 @@ void SpawnBoy(int lvl)
|
|||
break;
|
||||
}
|
||||
}
|
||||
} while (keepgoing || ((items[0]._iIvalue > 200000
|
||||
|| items[0]._iMinStr > strength
|
||||
|| items[0]._iMinMag > magic
|
||||
|| items[0]._iMinDex > dexterity
|
||||
|| items[0]._iIvalue < ivalue)
|
||||
&& count < 250));
|
||||
} while (keepgoing
|
||||
|| ((
|
||||
items[0]._iIvalue > 200000
|
||||
|| items[0]._iMinStr > strength
|
||||
|| items[0]._iMinMag > magic
|
||||
|| items[0]._iMinDex > dexterity
|
||||
|| items[0]._iIvalue < ivalue)
|
||||
&& count < 250));
|
||||
boyitem = items[0];
|
||||
boyitem._iCreateInfo = lvl | CF_BOY;
|
||||
boyitem._iIdentified = true;
|
||||
|
|
|
|||
|
|
@ -1919,10 +1919,10 @@ void SaveGameData()
|
|||
|
||||
file.writeLE<Uint8>(automapflag);
|
||||
file.writeBE<Sint32>(AutoMapScale);
|
||||
|
||||
}
|
||||
|
||||
void SaveGame() {
|
||||
void SaveGame()
|
||||
{
|
||||
gbValidSaveFile = true;
|
||||
pfile_write_hero(/*write_game_data=*/true);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -31,4 +31,4 @@ void SaveGame();
|
|||
void SaveLevel();
|
||||
void LoadLevel();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -14,4 +14,4 @@ extern char gszHero[16];
|
|||
bool mainmenu_select_hero_dialog(GameData *gameData);
|
||||
void mainmenu_loop();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -25,4 +25,4 @@ void DrawQTextBack(CelOutputBuffer out);
|
|||
*/
|
||||
void DrawQText(CelOutputBuffer out);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -115,4 +115,4 @@ typedef struct MisFileData {
|
|||
extern MissileData missiledata[];
|
||||
extern MisFileData misfiledata[];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -239,4 +239,4 @@ void ProcessMissiles();
|
|||
void missiles_process_charge();
|
||||
void ClearMissileSpot(int mi);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -285,4 +285,4 @@ extern const _monster_id MonstConvTbl[];
|
|||
extern const char MonstAvailTbl[];
|
||||
extern const UniqMonstStruct UniqMonst[];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -4030,7 +4030,7 @@ void MAI_Golum(int i)
|
|||
|
||||
md = left[md];
|
||||
for (j = 0; j < 8 && !ok; j++) {
|
||||
md = right[md];
|
||||
md = right[md];
|
||||
ok = DirOK(i, md);
|
||||
}
|
||||
if (ok)
|
||||
|
|
|
|||
|
|
@ -97,9 +97,11 @@ enum monster_goal : uint8_t {
|
|||
};
|
||||
|
||||
enum placeflag : uint8_t {
|
||||
// clang-format off
|
||||
PLACE_SCATTER = 1 << 0,
|
||||
PLACE_SPECIAL = 1 << 1,
|
||||
PLACE_UNIQUE = 1 << 2,
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
struct AnimStruct {
|
||||
|
|
@ -334,4 +336,4 @@ extern direction opposite[8];
|
|||
extern int offset_x[8];
|
||||
extern int offset_y[8];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -14,4 +14,4 @@ extern bool loop_movie;
|
|||
|
||||
void play_movie(const char *pszMovie, bool user_can_close);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -46,4 +46,4 @@ bool mpqapi_has_file(const char *pszName);
|
|||
bool OpenMPQ(const char *pszArchive, DWORD dwChar);
|
||||
bool mpqapi_flush_and_close(const char *pszArchive, bool bFree, DWORD dwChar);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -453,4 +453,4 @@ void NetSendCmdString(int pmask, const char *pszStr);
|
|||
void delta_close_portal(int pnum);
|
||||
DWORD ParseCmd(int pnum, TCmd *pCmd);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -63,4 +63,4 @@ bool multi_init_single(GameData *gameData);
|
|||
bool multi_init_multi(GameData *gameData, bool *pfExitProgram);
|
||||
void recv_plrinfo(int pnum, TCmdPlrInfoHdr *p, bool recv);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -33,4 +33,4 @@ bool nthread_has_500ms_passed();
|
|||
*/
|
||||
void nthread_UpdateProgressToNextGameTick();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -249,4 +249,4 @@ extern const char *const ObjMasterLoadList[];
|
|||
extern const char *ObjCryptLoadList[];
|
||||
extern const char *ObjHiveLoadList[];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -102,7 +102,7 @@ struct ControllerOptions {
|
|||
bool bDpadHotkeys;
|
||||
/** @brief Shoulder gamepad shoulder buttons act as potions by default */
|
||||
bool bSwapShoulderButtonMode;
|
||||
/** @brief Configure gamepad joysticks deadzone */
|
||||
/** @brief Configure gamepad joysticks deadzone */
|
||||
float fDeadzone;
|
||||
#ifdef __vita__
|
||||
/** @brief Enable input via rear touchpad */
|
||||
|
|
@ -137,4 +137,4 @@ struct Options {
|
|||
|
||||
extern Options sgOptions;
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -81,4 +81,4 @@ void UnPackPlayer(PkPlayerStruct *pPack, int pnum, bool netSync);
|
|||
void PackItem(PkItemStruct *id, const ItemStruct *is);
|
||||
void UnPackItem(const PkItemStruct *is, ItemStruct *id, bool isHellfire);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -52,4 +52,4 @@ void palette_update_crypt();
|
|||
void palette_update_hive();
|
||||
void palette_update_quest_palette(int n);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -41,4 +41,4 @@ PATHNODE *path_new_step();
|
|||
extern const char pathxdir[8];
|
||||
extern const char pathydir[8];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@
|
|||
#include <stdbool.h>
|
||||
|
||||
#include <SDL.h>
|
||||
#include <psp2/types.h>
|
||||
#include <psp2/ime_dialog.h>
|
||||
#include <psp2/types.h>
|
||||
#include <psp2/ime_dialog.h>
|
||||
#include "platform/vita/keyboard.h"
|
||||
|
||||
static void utf16_to_utf8(const uint16_t *src, uint8_t *dst)
|
||||
|
|
@ -12,10 +12,10 @@ static void utf16_to_utf8(const uint16_t *src, uint8_t *dst)
|
|||
for (i = 0; src[i]; i++) {
|
||||
if ((src[i] & 0xFF80) == 0) {
|
||||
*(dst++) = src[i] & 0xFF;
|
||||
} else if((src[i] & 0xF800) == 0) {
|
||||
} else if ((src[i] & 0xF800) == 0) {
|
||||
*(dst++) = ((src[i] >> 6) & 0xFF) | 0xC0;
|
||||
*(dst++) = (src[i] & 0x3F) | 0x80;
|
||||
} else if((src[i] & 0xFC00) == 0xD800 && (src[i + 1] & 0xFC00) == 0xDC00) {
|
||||
} else if ((src[i] & 0xFC00) == 0xD800 && (src[i + 1] & 0xFC00) == 0xDC00) {
|
||||
*(dst++) = (((src[i] + 64) >> 8) & 0x3) | 0xF0;
|
||||
*(dst++) = (((src[i] >> 2) + 16) & 0x3F) | 0x80;
|
||||
*(dst++) = ((src[i] >> 4) & 0x30) | 0x80 | ((src[i + 1] << 2) & 0xF);
|
||||
|
|
@ -52,7 +52,7 @@ static void utf8_to_utf16(const uint8_t *src, uint16_t *dst)
|
|||
|
||||
static int vita_input_thread(void *ime_buffer)
|
||||
{
|
||||
while(1) {
|
||||
while (1) {
|
||||
// update IME status. Terminate, if finished
|
||||
SceCommonDialogStatus dialogStatus = sceImeDialogGetStatus();
|
||||
if (dialogStatus == SCE_COMMON_DIALOG_STATUS_FINISHED) {
|
||||
|
|
@ -63,12 +63,12 @@ static int vita_input_thread(void *ime_buffer)
|
|||
sceImeDialogGetResult(&result);
|
||||
|
||||
// Convert UTF16 to UTF8
|
||||
utf16_to_utf8((SceWChar16*)ime_buffer, utf8_buffer);
|
||||
utf16_to_utf8((SceWChar16 *)ime_buffer, utf8_buffer);
|
||||
|
||||
// send sdl event
|
||||
SDL_Event event;
|
||||
event.text.type = SDL_TEXTINPUT;
|
||||
SDL_utf8strlcpy(event.text.text, (const char*)utf8_buffer, SDL_arraysize(event.text.text));
|
||||
SDL_utf8strlcpy(event.text.text, (const char *)utf8_buffer, SDL_arraysize(event.text.text));
|
||||
SDL_PushEvent(&event);
|
||||
|
||||
sceImeDialogTerm();
|
||||
|
|
@ -86,8 +86,8 @@ static int vita_keyboard_get(const char *guide_text, const char *initial_text, i
|
|||
|
||||
SDL_memset(&title, 0, sizeof(title));
|
||||
SDL_memset(&text, 0, sizeof(text));
|
||||
utf8_to_utf16((const uint8_t*)guide_text, title);
|
||||
utf8_to_utf16((const uint8_t*)initial_text, text);
|
||||
utf8_to_utf16((const uint8_t *)guide_text, title);
|
||||
utf8_to_utf16((const uint8_t *)initial_text, text);
|
||||
|
||||
SceImeDialogParam param;
|
||||
sceImeDialogParamInit(¶m);
|
||||
|
|
@ -116,5 +116,5 @@ void vita_start_text_input(const char *guide_text, const char *initial_text, int
|
|||
SceWChar16 ime_buffer[SCE_IME_DIALOG_MAX_TEXT_LENGTH];
|
||||
if (vita_keyboard_get(guide_text, initial_text, max_length, ime_buffer)) {
|
||||
SDL_CreateThread(vita_input_thread, "vita_input_thread", (void *)ime_buffer);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -3699,7 +3699,7 @@ void ProcessPlayerAnimation(int pnum)
|
|||
}
|
||||
}
|
||||
|
||||
Sint32 GetFrameToUseForPlayerRendering(const PlayerStruct* pPlayer)
|
||||
Sint32 GetFrameToUseForPlayerRendering(const PlayerStruct *pPlayer)
|
||||
{
|
||||
// Normal logic is used,
|
||||
// - if no frame-skipping is required and so we have exactly one Animationframe per GameTick (_pAnimUsedNumFrames = 0)
|
||||
|
|
@ -3720,13 +3720,17 @@ Sint32 GetFrameToUseForPlayerRendering(const PlayerStruct* pPlayer)
|
|||
relevantAnimationLength = pPlayer->_pAnimLen;
|
||||
}
|
||||
float progressToNextGameTick = gfProgressToNextGameTick;
|
||||
float totalGameTicksForCurrentAnimationSequence = progressToNextGameTick + (float)pPlayer->_pAnimGameTicksSinceSequenceStarted; // we don't use the processed game ticks alone but also the fragtion of the next game tick (if a rendering happens between game ticks). This helps to smooth the animations.
|
||||
// we don't use the processed game ticks alone but also the fragtion of the next game tick (if a rendering happens between game ticks). This helps to smooth the animations.
|
||||
float totalGameTicksForCurrentAnimationSequence = progressToNextGameTick + (float)pPlayer->_pAnimGameTicksSinceSequenceStarted;
|
||||
int animationMaxGameTickets = relevantAnimationLength;
|
||||
if (pPlayer->_pAnimDelay > 1)
|
||||
animationMaxGameTickets = (relevantAnimationLength * pPlayer->_pAnimDelay);
|
||||
float gameTickModifier = (float)animationMaxGameTickets / (float)(relevantAnimationLength - pPlayer->_pAnimNumSkippedFrames); // if we skipped Frames we need to expand the GameTicks to make one GameTick for this Animation "faster"
|
||||
int absolutAnimationFrame = 1 + (int)(totalGameTicksForCurrentAnimationSequence * gameTickModifier); // 1 added for rounding reasons. float to int cast always truncate.
|
||||
if (absolutAnimationFrame > relevantAnimationLength) // this can happen if we are at the last frame and the next game tick is due (nthread_GetProgressToNextGameTick returns 1.0f)
|
||||
// if we skipped Frames we need to expand the GameTicks to make one GameTick for this Animation "faster"
|
||||
float gameTickModifier = (float)animationMaxGameTickets / (float)(relevantAnimationLength - pPlayer->_pAnimNumSkippedFrames);
|
||||
// 1 added for rounding reasons. float to int cast always truncate.
|
||||
int absolutAnimationFrame = 1 + (int)(totalGameTicksForCurrentAnimationSequence * gameTickModifier);
|
||||
// this can happen if we are at the last frame and the next game tick is due (nthread_GetProgressToNextGameTick returns 1.0f)
|
||||
if (absolutAnimationFrame > relevantAnimationLength)
|
||||
return relevantAnimationLength;
|
||||
if (absolutAnimationFrame <= 0) {
|
||||
SDL_Log("GetFrameToUseForPlayerRendering: Calculated an invalid Animation Frame");
|
||||
|
|
|
|||
|
|
@ -23,4 +23,4 @@ void ClearPlrMsg();
|
|||
void InitPlrMsg();
|
||||
void DrawPlrMsg(CelOutputBuffer out);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -36,4 +36,4 @@ void GetPortalLevel();
|
|||
void GetPortalLvlPos();
|
||||
bool PosOkPortal(int lvl, int x, int y);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -95,4 +95,4 @@ void SetMultiQuest(int q, quest_state s, int l, int v1);
|
|||
/* rdata */
|
||||
extern QuestData questlist[];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -437,7 +437,8 @@ inline void DoRenderLine(BYTE *dst, BYTE *src, int n, BYTE *tbl, DWORD mask)
|
|||
#if DVL_HAVE_ATTRIBUTE(always_inline) || (defined(__GNUC__) && !defined(__clang__))
|
||||
__attribute__((always_inline))
|
||||
#endif
|
||||
inline void RenderLine(BYTE *dst_begin, BYTE *dst_end, BYTE **dst, BYTE **src, int n, BYTE *tbl, DWORD mask)
|
||||
inline void
|
||||
RenderLine(BYTE *dst_begin, BYTE *dst_end, BYTE **dst, BYTE **src, int n, BYTE *tbl, DWORD mask)
|
||||
{
|
||||
#ifdef NO_OVERDRAW
|
||||
if (*dst >= dst_begin && *dst <= dst_end)
|
||||
|
|
@ -453,7 +454,8 @@ inline void RenderLine(BYTE *dst_begin, BYTE *dst_end, BYTE **dst, BYTE **src, i
|
|||
__attribute__((no_sanitize("shift-base")))
|
||||
#endif
|
||||
|
||||
void RenderTile(CelOutputBuffer out, int x, int y)
|
||||
void
|
||||
RenderTile(CelOutputBuffer out, int x, int y)
|
||||
{
|
||||
int i, j;
|
||||
char c, v, tile;
|
||||
|
|
|
|||
|
|
@ -61,4 +61,4 @@ void EnableFrameCount();
|
|||
void scrollrt_draw_game_screen(bool draw_cursor);
|
||||
void DrawAndBlit();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -13,4 +13,4 @@ void LoadSetMap();
|
|||
/* rdata */
|
||||
extern const char *const quest_level_names[];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -22,4 +22,4 @@ void SHA1Result(int n, char Message_Digest[SHA1HashSize]);
|
|||
void SHA1Calculate(int n, const char *data, char Message_Digest[SHA1HashSize]);
|
||||
void SHA1Reset(int n);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -57,4 +57,4 @@ extern bool gbMusicOn;
|
|||
extern bool gbSoundOn;
|
||||
extern bool gbDupSounds;
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -219,4 +219,4 @@ struct SpellData {
|
|||
|
||||
extern SpellData spelldata[];
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -20,4 +20,4 @@ void DoHealOther(int pnum, int rid);
|
|||
int GetSpellBookLevel(spell_id s);
|
||||
int GetSpellStaffLevel(spell_id s);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -116,4 +116,4 @@ void STextEnter();
|
|||
void CheckStoreBtn();
|
||||
void ReleaseStoreBtn();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -277,15 +277,15 @@ bool getIniBool(const char *sectionName, const char *keyName, bool defaultValue)
|
|||
|
||||
float getIniFloat(const char *sectionName, const char *keyName, float defaultValue)
|
||||
{
|
||||
radon::Section *section = getIni().getSection(sectionName);
|
||||
if (!section)
|
||||
return defaultValue;
|
||||
radon::Section *section = getIni().getSection(sectionName);
|
||||
if (!section)
|
||||
return defaultValue;
|
||||
|
||||
radon::Key *key = section->getKey(keyName);
|
||||
if (!key)
|
||||
return defaultValue;
|
||||
radon::Key *key = section->getKey(keyName);
|
||||
if (!key)
|
||||
return defaultValue;
|
||||
|
||||
return key->getFloatValue();
|
||||
return key->getFloatValue();
|
||||
}
|
||||
|
||||
bool getIniValue(const char *sectionName, const char *keyName, char *string, int stringSize, const char *defaultString)
|
||||
|
|
|
|||
|
|
@ -103,10 +103,10 @@ struct CCritSect {
|
|||
|
||||
// Game states
|
||||
#define GAMESTATE_PRIVATE 0x01
|
||||
#define GAMESTATE_FULL 0x02
|
||||
#define GAMESTATE_ACTIVE 0x04
|
||||
#define GAMESTATE_FULL 0x02
|
||||
#define GAMESTATE_ACTIVE 0x04
|
||||
#define GAMESTATE_STARTED 0x08
|
||||
#define GAMESTATE_REPLAY 0x80
|
||||
#define GAMESTATE_REPLAY 0x80
|
||||
|
||||
#define PS_CONNECTED 0x10000
|
||||
#define PS_TURN_ARRIVED 0x20000
|
||||
|
|
@ -155,9 +155,8 @@ bool SNetGetGameInfo(game_info type, void *dst, unsigned int length);
|
|||
*
|
||||
* Returns true if the function was called successfully and false otherwise.
|
||||
*/
|
||||
bool
|
||||
SNetGetTurnsInTransit(
|
||||
DWORD *turns);
|
||||
bool SNetGetTurnsInTransit(
|
||||
DWORD *turns);
|
||||
|
||||
// Network provider structures
|
||||
typedef struct _client_info {
|
||||
|
|
@ -202,7 +201,7 @@ bool SNetPerformUpgrade(DWORD *upgradestatus);
|
|||
bool SNetReceiveMessage(int *senderplayerid, char **data, int *databytes);
|
||||
bool SNetReceiveTurns(int a1, int arraysize, char **arraydata, DWORD *arraydatabytes, DWORD *arrayplayerstatus);
|
||||
|
||||
typedef void(*SEVTHANDLER)(struct _SNETEVENT *);
|
||||
typedef void (*SEVTHANDLER)(struct _SNETEVENT *);
|
||||
|
||||
/* SNetSendMessage @ 127
|
||||
*
|
||||
|
|
@ -222,7 +221,7 @@ typedef void(*SEVTHANDLER)(struct _SNETEVENT *);
|
|||
bool SNetSendMessage(int playerID, void *data, unsigned int databytes);
|
||||
|
||||
// Macro values to target specific players
|
||||
#define SNPLAYER_ALL -1
|
||||
#define SNPLAYER_ALL -1
|
||||
#define SNPLAYER_OTHERS -2
|
||||
|
||||
#define MPQ_FLAG_READ_ONLY 1
|
||||
|
|
@ -250,7 +249,7 @@ bool WINAPI SFileCloseArchive(HANDLE hArchive);
|
|||
bool WINAPI SFileOpenFileEx(HANDLE hMpq, const char *szFileName, DWORD dwSearchScope, HANDLE *phFile);
|
||||
bool WINAPI SFileReadFile(HANDLE hFile, void *buffer, DWORD nNumberOfBytesToRead, DWORD *read, LONG *lpDistanceToMoveHigh);
|
||||
DWORD WINAPI SFileGetFileSize(HANDLE hFile, LPDWORD lpFileSizeHigh);
|
||||
DWORD WINAPI SFileSetFilePointer(HANDLE, int, int*, int);
|
||||
DWORD WINAPI SFileSetFilePointer(HANDLE, int, int *, int);
|
||||
bool WINAPI SFileCloseFile(HANDLE hFile);
|
||||
|
||||
/* SBmpLoadImage @ 323
|
||||
|
|
@ -267,15 +266,14 @@ bool WINAPI SFileCloseFile(HANDLE hFile);
|
|||
*
|
||||
* Returns true if the image was supported and loaded correctly, false otherwise.
|
||||
*/
|
||||
bool
|
||||
SBmpLoadImage(
|
||||
const char *pszFileName,
|
||||
SDL_Color *pPalette,
|
||||
BYTE *pBuffer,
|
||||
DWORD dwBuffersize,
|
||||
DWORD *pdwWidth,
|
||||
DWORD *pdwHeight,
|
||||
DWORD *pdwBpp);
|
||||
bool SBmpLoadImage(
|
||||
const char *pszFileName,
|
||||
SDL_Color *pPalette,
|
||||
BYTE *pBuffer,
|
||||
DWORD dwBuffersize,
|
||||
DWORD *pdwWidth,
|
||||
DWORD *pdwHeight,
|
||||
DWORD *pdwBpp);
|
||||
|
||||
bool getIniBool(const char *sectionName, const char *keyName, bool defaultValue = false);
|
||||
float getIniFloat(const char *sectionName, const char *keyName, float defaultValue);
|
||||
|
|
@ -318,11 +316,11 @@ DWORD SErrGetLastError();
|
|||
void SErrSetLastError(DWORD dwErrCode);
|
||||
|
||||
// Values for dwErrCode
|
||||
#define STORM_ERROR_GAME_TERMINATED 0x85100069
|
||||
#define STORM_ERROR_INVALID_PLAYER 0x8510006a
|
||||
#define STORM_ERROR_NO_MESSAGES_WAITING 0x8510006b
|
||||
#define STORM_ERROR_NOT_IN_GAME 0x85100070
|
||||
#define STORM_ERROR_REQUIRES_UPGRADE 0x85100077
|
||||
#define STORM_ERROR_GAME_TERMINATED 0x85100069
|
||||
#define STORM_ERROR_INVALID_PLAYER 0x8510006a
|
||||
#define STORM_ERROR_NO_MESSAGES_WAITING 0x8510006b
|
||||
#define STORM_ERROR_NOT_IN_GAME 0x85100070
|
||||
#define STORM_ERROR_REQUIRES_UPGRADE 0x85100077
|
||||
|
||||
/* SStrCopy @ 501
|
||||
*
|
||||
|
|
@ -354,18 +352,18 @@ bool SFileEnableDirectAccess(bool enable);
|
|||
// Sets the file's 64-bit seek position.
|
||||
inline std::uint64_t SFileSetFilePointer(HANDLE hFile, std::int64_t offset, int whence)
|
||||
{
|
||||
int high = static_cast<std::uint64_t>(offset) >> 32;
|
||||
int low = static_cast<int>(offset);
|
||||
low = SFileSetFilePointer(hFile, low, &high, whence);
|
||||
return (static_cast<std::uint64_t>(high) << 32) | low;
|
||||
int high = static_cast<std::uint64_t>(offset) >> 32;
|
||||
int low = static_cast<int>(offset);
|
||||
low = SFileSetFilePointer(hFile, low, &high, whence);
|
||||
return (static_cast<std::uint64_t>(high) << 32) | low;
|
||||
}
|
||||
|
||||
// Returns the current 64-bit file seek position.
|
||||
inline std::uint64_t SFileGetFilePointer(HANDLE hFile)
|
||||
{
|
||||
// We use `SFileSetFilePointer` with offset 0 to get the current position
|
||||
// because there is no `SFileGetFilePointer`.
|
||||
return SFileSetFilePointer(hFile, 0, DVL_FILE_CURRENT);
|
||||
// We use `SFileSetFilePointer` with offset 0 to get the current position
|
||||
// because there is no `SFileGetFilePointer`.
|
||||
return SFileSetFilePointer(hFile, 0, DVL_FILE_CURRENT);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ Uint32 sync_all_monsters(const Uint8 *pbBuf, Uint32 dwMaxLen);
|
|||
Uint32 sync_update(int pnum, const Uint8 *pbBuf);
|
||||
void sync_init();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -25,4 +25,4 @@ void InitThemes();
|
|||
void HoldThemeRooms();
|
||||
void CreateThemeRooms();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -29,4 +29,4 @@ void tmsg_add(Uint8 *pbMsg, Uint8 bLen);
|
|||
void tmsg_start();
|
||||
void tmsg_cleanup();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -14,4 +14,4 @@ void TownOpenHive();
|
|||
void TownOpenGrave();
|
||||
void CreateTown(lvl_entry entry);
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -43,8 +43,8 @@ struct TownerStruct {
|
|||
uint8_t *_tNData;
|
||||
uint8_t *_tAnimData;
|
||||
int16_t _tSeed;
|
||||
int16_t _tx; // Tile X-position of NPC
|
||||
int16_t _ty; // Tile Y-position of NPC
|
||||
int16_t _tx; // Tile X-position of NPC
|
||||
int16_t _ty; // Tile Y-position of NPC
|
||||
int16_t _tAnimWidth;
|
||||
int16_t _tAnimWidth2;
|
||||
int16_t _tAnimDelay; // Tick length of each frame in the current animation
|
||||
|
|
|
|||
|
|
@ -11,4 +11,4 @@ void track_process();
|
|||
void track_repeat_walk(bool rep);
|
||||
bool track_isscrolling();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -37,4 +37,4 @@ void Freeupstairs();
|
|||
void CheckTrigForce();
|
||||
void CheckTriggers();
|
||||
|
||||
}
|
||||
} // namespace devilution
|
||||
|
|
|
|||
|
|
@ -27,24 +27,24 @@ std::string *ttfName = NULL;
|
|||
void AddTrailingSlash(std::string *path)
|
||||
{
|
||||
#ifdef _WIN32
|
||||
if (!path->empty() && path->back() != '\\')
|
||||
*path += '\\';
|
||||
if (!path->empty() && path->back() != '\\')
|
||||
*path += '\\';
|
||||
#else
|
||||
if (!path->empty() && path->back() != '/')
|
||||
*path += '/';
|
||||
if (!path->empty() && path->back() != '/')
|
||||
*path += '/';
|
||||
#endif
|
||||
}
|
||||
|
||||
std::string *FromSDL(char *s)
|
||||
{
|
||||
std::string *result = new std::string(s != NULL ? s : "");
|
||||
if (s != NULL) {
|
||||
SDL_free(s);
|
||||
} else {
|
||||
SDL_Log("%s", SDL_GetError());
|
||||
SDL_ClearError();
|
||||
}
|
||||
return result;
|
||||
std::string *result = new std::string(s != NULL ? s : "");
|
||||
if (s != NULL) {
|
||||
SDL_free(s);
|
||||
} else {
|
||||
SDL_Log("%s", SDL_GetError());
|
||||
SDL_ClearError();
|
||||
}
|
||||
return result;
|
||||
}
|
||||
|
||||
} // namespace
|
||||
|
|
|
|||
|
|
@ -10,8 +10,10 @@
|
|||
#if !SDL_VERSION_ATLEAST(2, 0, 4)
|
||||
inline SDL_bool SDL_PointInRect(const SDL_Point *p, const SDL_Rect *r)
|
||||
{
|
||||
return ( (p->x >= r->x) && (p->x < (r->x + r->w)) &&
|
||||
(p->y >= r->y) && (p->y < (r->y + r->h)) ) ? SDL_TRUE : SDL_FALSE;
|
||||
return ((p->x >= r->x) && (p->x < (r->x + r->w))
|
||||
&& (p->y >= r->y) && (p->y < (r->y + r->h)))
|
||||
? SDL_TRUE
|
||||
: SDL_FALSE;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
|||
|
|
@ -55,26 +55,25 @@
|
|||
#define SDL_JoystickNameForIndex SDL_JoystickName
|
||||
|
||||
enum SDL_LogCategory {
|
||||
SDL_LOG_CATEGORY_APPLICATION,
|
||||
SDL_LOG_CATEGORY_ERROR,
|
||||
SDL_LOG_CATEGORY_ASSERT,
|
||||
SDL_LOG_CATEGORY_SYSTEM,
|
||||
SDL_LOG_CATEGORY_AUDIO,
|
||||
SDL_LOG_CATEGORY_VIDEO,
|
||||
SDL_LOG_CATEGORY_RENDER,
|
||||
SDL_LOG_CATEGORY_INPUT,
|
||||
SDL_LOG_CATEGORY_TEST,
|
||||
SDL_LOG_CATEGORY_APPLICATION,
|
||||
SDL_LOG_CATEGORY_ERROR,
|
||||
SDL_LOG_CATEGORY_ASSERT,
|
||||
SDL_LOG_CATEGORY_SYSTEM,
|
||||
SDL_LOG_CATEGORY_AUDIO,
|
||||
SDL_LOG_CATEGORY_VIDEO,
|
||||
SDL_LOG_CATEGORY_RENDER,
|
||||
SDL_LOG_CATEGORY_INPUT,
|
||||
SDL_LOG_CATEGORY_TEST,
|
||||
};
|
||||
|
||||
enum SDL_LogPriority
|
||||
{
|
||||
SDL_LOG_PRIORITY_VERBOSE = 1,
|
||||
SDL_LOG_PRIORITY_DEBUG,
|
||||
SDL_LOG_PRIORITY_INFO,
|
||||
SDL_LOG_PRIORITY_WARN,
|
||||
SDL_LOG_PRIORITY_ERROR,
|
||||
SDL_LOG_PRIORITY_CRITICAL,
|
||||
SDL_NUM_LOG_PRIORITIES
|
||||
enum SDL_LogPriority {
|
||||
SDL_LOG_PRIORITY_VERBOSE = 1,
|
||||
SDL_LOG_PRIORITY_DEBUG,
|
||||
SDL_LOG_PRIORITY_INFO,
|
||||
SDL_LOG_PRIORITY_WARN,
|
||||
SDL_LOG_PRIORITY_ERROR,
|
||||
SDL_LOG_PRIORITY_CRITICAL,
|
||||
SDL_NUM_LOG_PRIORITIES
|
||||
};
|
||||
|
||||
void SDL_Log(const char *fmt, ...) DVL_PRINTF_ATTRIBUTE(1, 2);
|
||||
|
|
|
|||
|
|
@ -4,16 +4,16 @@
|
|||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#define UNIMPLEMENTED() \
|
||||
do { \
|
||||
#define UNIMPLEMENTED() \
|
||||
do { \
|
||||
SDL_Log("UNIMPLEMENTED: %s @ %s:%d", __FUNCTION__, __FILE__, __LINE__); \
|
||||
abort(); \
|
||||
abort(); \
|
||||
} while (0)
|
||||
|
||||
#define ABORT() \
|
||||
do { \
|
||||
#define ABORT() \
|
||||
do { \
|
||||
SDL_Log("ABORT: %s @ %s:%d", __FUNCTION__, __FILE__, __LINE__); \
|
||||
abort(); \
|
||||
abort(); \
|
||||
} while (0)
|
||||
|
||||
#define ASSERT(x) \
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue