Commit 71e967d8 authored by nanahira's avatar nanahira

Merge branch 'master' of github.com:Fluorohydride/ygopro

parents 3ae502e1 0220053e
...@@ -7,35 +7,35 @@ ...@@ -7,35 +7,35 @@
class BufferIO { class BufferIO {
public: public:
inline static int ReadInt32(char*& p) { inline static int ReadInt32(unsigned char*& p) {
int ret = *(int*)p; int ret = *(int*)p;
p += 4; p += 4;
return ret; return ret;
} }
inline static short ReadInt16(char*& p) { inline static short ReadInt16(unsigned char*& p) {
short ret = *(short*)p; short ret = *(short*)p;
p += 2; p += 2;
return ret; return ret;
} }
inline static char ReadInt8(char*& p) { inline static char ReadInt8(unsigned char*& p) {
char ret = *(char*)p; char ret = *(char*)p;
p++; p++;
return ret; return ret;
} }
inline static unsigned char ReadUInt8(char*& p) { inline static unsigned char ReadUInt8(unsigned char*& p) {
unsigned char ret = *(unsigned char*)p; unsigned char ret = *(unsigned char*)p;
p++; p++;
return ret; return ret;
} }
inline static void WriteInt32(char*& p, int val) { inline static void WriteInt32(unsigned char*& p, int val) {
(*(int*)p) = val; (*(int*)p) = val;
p += 4; p += 4;
} }
inline static void WriteInt16(char*& p, short val) { inline static void WriteInt16(unsigned char*& p, short val) {
(*(short*)p) = val; (*(short*)p) = val;
p += 2; p += 2;
} }
inline static void WriteInt8(char*& p, char val) { inline static void WriteInt8(unsigned char*& p, char val) {
*p = val; *p = val;
p++; p++;
} }
......
...@@ -5,50 +5,27 @@ ...@@ -5,50 +5,27 @@
namespace ygo { namespace ygo {
ClientCard::ClientCard() { ClientCard::~ClientCard() {
curAlpha = 255; ClearTarget();
dAlpha = 0; if (equipTarget)
aniFrame = 0; equipTarget->equipped.erase(this);
is_moving = false; for (auto card : equipped) {
is_fading = false; card->equipTarget = nullptr;
is_hovered = false; }
is_selectable = false; equipped.clear();
is_selected = false; if (overlayTarget) {
is_showequip = false; for (auto it = overlayTarget->overlayed.begin(); it != overlayTarget->overlayed.end(); ) {
is_showtarget = false; if (*it == this) {
is_showchaintarget = false; it = overlayTarget->overlayed.erase(it);
is_highlighting = false; }
status = 0; else
is_reversed = false; ++it;
cmdFlag = 0; }
code = 0; }
chain_code = 0; for (auto card : overlayed) {
location = 0; card->overlayTarget = nullptr;
type = 0; }
alias = 0; overlayed.clear();
level = 0;
rank = 0;
link = 0;
race = 0;
attribute = 0;
attack = 0;
defense = 0;
base_attack = 0;
base_defense = 0;
lscale = 0;
rscale = 0;
link_marker = 0;
position = 0;
cHint = 0;
chValue = 0;
atkstring[0] = 0;
defstring[0] = 0;
lvstring[0] = 0;
linkstring[0] = 0;
rscstring[0] = 0;
lscstring[0] = 0;
overlayTarget = 0;
equipTarget = 0;
} }
void ClientCard::SetCode(int code) { void ClientCard::SetCode(int code) {
if((location == LOCATION_HAND) && (this->code != (unsigned int)code)) { if((location == LOCATION_HAND) && (this->code != (unsigned int)code)) {
...@@ -57,13 +34,16 @@ void ClientCard::SetCode(int code) { ...@@ -57,13 +34,16 @@ void ClientCard::SetCode(int code) {
} else } else
this->code = code; this->code = code;
} }
void ClientCard::UpdateInfo(char* buf) { void ClientCard::UpdateInfo(unsigned char* buf) {
int flag = BufferIO::ReadInt32(buf); int flag = BufferIO::ReadInt32(buf);
if(flag == 0) if (flag == 0) {
ClearData();
return; return;
int pdata; }
if(flag & QUERY_CODE) { if(flag & QUERY_CODE) {
pdata = BufferIO::ReadInt32(buf); int pdata = BufferIO::ReadInt32(buf);
if (!pdata)
ClearData();
if((location == LOCATION_HAND) && ((unsigned int)pdata != code)) { if((location == LOCATION_HAND) && ((unsigned int)pdata != code)) {
code = pdata; code = pdata;
mainGame->dField.MoveCard(this, 5); mainGame->dField.MoveCard(this, 5);
...@@ -71,7 +51,7 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -71,7 +51,7 @@ void ClientCard::UpdateInfo(char* buf) {
code = pdata; code = pdata;
} }
if(flag & QUERY_POSITION) { if(flag & QUERY_POSITION) {
pdata = (BufferIO::ReadInt32(buf) >> 24) & 0xff; int pdata = (BufferIO::ReadInt32(buf) >> 24) & 0xff;
if((location & (LOCATION_EXTRA | LOCATION_REMOVED)) && (u8)pdata != position) { if((location & (LOCATION_EXTRA | LOCATION_REMOVED)) && (u8)pdata != position) {
position = pdata; position = pdata;
mainGame->dField.MoveCard(this, 1); mainGame->dField.MoveCard(this, 1);
...@@ -83,14 +63,14 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -83,14 +63,14 @@ void ClientCard::UpdateInfo(char* buf) {
if(flag & QUERY_TYPE) if(flag & QUERY_TYPE)
type = BufferIO::ReadInt32(buf); type = BufferIO::ReadInt32(buf);
if(flag & QUERY_LEVEL) { if(flag & QUERY_LEVEL) {
pdata = BufferIO::ReadInt32(buf); int pdata = BufferIO::ReadInt32(buf);
if(level != (unsigned int)pdata) { if(level != (unsigned int)pdata) {
level = pdata; level = pdata;
myswprintf(lvstring, L"L%d", level); myswprintf(lvstring, L"L%d", level);
} }
} }
if(flag & QUERY_RANK) { if(flag & QUERY_RANK) {
pdata = BufferIO::ReadInt32(buf); int pdata = BufferIO::ReadInt32(buf);
if(pdata && rank != (unsigned int)pdata) { if(pdata && rank != (unsigned int)pdata) {
rank = pdata; rank = pdata;
myswprintf(lvstring, L"R%d", rank); myswprintf(lvstring, L"R%d", rank);
...@@ -133,8 +113,10 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -133,8 +113,10 @@ void ClientCard::UpdateInfo(char* buf) {
int s = BufferIO::ReadInt8(buf); int s = BufferIO::ReadInt8(buf);
BufferIO::ReadInt8(buf); BufferIO::ReadInt8(buf);
ClientCard* ecard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s); ClientCard* ecard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s);
equipTarget = ecard; if (ecard) {
ecard->equipped.insert(this); equipTarget = ecard;
ecard->equipped.insert(this);
}
} }
if(flag & QUERY_TARGET_CARD) { if(flag & QUERY_TARGET_CARD) {
int count = BufferIO::ReadInt32(buf); int count = BufferIO::ReadInt32(buf);
...@@ -144,8 +126,10 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -144,8 +126,10 @@ void ClientCard::UpdateInfo(char* buf) {
int s = BufferIO::ReadInt8(buf); int s = BufferIO::ReadInt8(buf);
BufferIO::ReadInt8(buf); BufferIO::ReadInt8(buf);
ClientCard* tcard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s); ClientCard* tcard = mainGame->dField.GetCard(mainGame->LocalPlayer(c), l, s);
cardTarget.insert(tcard); if (tcard) {
tcard->ownerTarget.insert(this); cardTarget.insert(tcard);
tcard->ownerTarget.insert(this);
}
} }
} }
if(flag & QUERY_OVERLAY_CARD) { if(flag & QUERY_OVERLAY_CARD) {
...@@ -175,7 +159,7 @@ void ClientCard::UpdateInfo(char* buf) { ...@@ -175,7 +159,7 @@ void ClientCard::UpdateInfo(char* buf) {
myswprintf(rscstring, L"%d", rscale); myswprintf(rscstring, L"%d", rscale);
} }
if(flag & QUERY_LINK) { if(flag & QUERY_LINK) {
pdata = BufferIO::ReadInt32(buf); int pdata = BufferIO::ReadInt32(buf);
if (link != (unsigned int)pdata) { if (link != (unsigned int)pdata) {
link = pdata; link = pdata;
} }
...@@ -198,6 +182,35 @@ void ClientCard::ClearTarget() { ...@@ -198,6 +182,35 @@ void ClientCard::ClearTarget() {
cardTarget.clear(); cardTarget.clear();
ownerTarget.clear(); ownerTarget.clear();
} }
void ClientCard::ClearData() {
alias = 0;
type = 0;
level = 0;
rank = 0;
race = 0;
attribute = 0;
attack = 0;
defense = 0;
base_attack = 0;
base_defense = 0;
lscale = 0;
rscale = 0;
link = 0;
link_marker = 0;
status = 0;
atkstring[0] = 0;
defstring[0] = 0;
lvstring[0] = 0;
linkstring[0] = 0;
rscstring[0] = 0;
lscstring[0] = 0;
counters.clear();
for (auto card : equipped) {
card->equipTarget = nullptr;
}
equipped.clear();
}
bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) { bool ClientCard::client_card_sort(ClientCard* c1, ClientCard* c2) {
if(c1->is_selected != c2->is_selected) if(c1->is_selected != c2->is_selected)
return c1->is_selected < c2->is_selected; return c1->is_selected < c2->is_selected;
......
...@@ -2,6 +2,7 @@ ...@@ -2,6 +2,7 @@
#define CLIENT_CARD_H #define CLIENT_CARD_H
#include "config.h" #include "config.h"
#include "../ocgcore/card_data.h"
#include <vector> #include <vector>
#include <set> #include <set>
#include <map> #include <map>
...@@ -9,20 +10,7 @@ ...@@ -9,20 +10,7 @@
namespace ygo { namespace ygo {
struct CardData { using CardData = card_data;
unsigned int code;
unsigned int alias;
unsigned long long setcode;
unsigned int type;
unsigned int level;
unsigned int attribute;
unsigned int race;
int attack;
int defense;
unsigned int lscale;
unsigned int rscale;
unsigned int link_marker;
};
struct CardDataC { struct CardDataC {
unsigned int code; unsigned int code;
unsigned int alias; unsigned int alias;
...@@ -53,67 +41,70 @@ public: ...@@ -53,67 +41,70 @@ public:
irr::core::vector3df curRot; irr::core::vector3df curRot;
irr::core::vector3df dPos; irr::core::vector3df dPos;
irr::core::vector3df dRot; irr::core::vector3df dRot;
u32 curAlpha; u32 curAlpha{ 255 };
u32 dAlpha; u32 dAlpha{ 0 };
u32 aniFrame; u32 aniFrame{ 0 };
bool is_moving; bool is_moving{ false };
bool is_fading; bool is_fading{ false };
bool is_hovered; bool is_hovered{ false };
bool is_selectable; bool is_selectable{ false };
bool is_selected; bool is_selected{ false };
bool is_showequip; bool is_showequip{ false };
bool is_showtarget; bool is_showtarget{ false };
bool is_showchaintarget; bool is_showchaintarget{ false };
bool is_highlighting; bool is_highlighting{ false };
bool is_reversed; bool is_reversed{ false };
u32 code;
u32 chain_code; unsigned int code{ 0 };
u32 alias; unsigned int chain_code{ 0 };
u32 type; unsigned int alias{ 0 };
u32 level; unsigned int type{ 0 };
u32 rank; unsigned int level{ 0 };
u32 link; unsigned int rank{ 0 };
u32 attribute; unsigned int link{ 0 };
u32 race; unsigned int attribute{ 0 };
s32 attack; unsigned int race{ 0 };
s32 defense; int attack{ 0 };
s32 base_attack; int defense{ 0 };
s32 base_defense; int base_attack{ 0 };
u32 lscale; int base_defense{ 0 };
u32 rscale; unsigned int lscale{ 0 };
u32 link_marker; unsigned int rscale{ 0 };
u32 reason; unsigned int link_marker{ 0 };
u32 select_seq; unsigned int reason{ 0 };
u8 owner; unsigned int select_seq{ 0 };
u8 controler; unsigned char owner{ PLAYER_NONE };
u8 location; unsigned char controler{ PLAYER_NONE };
u8 sequence; unsigned char location{ 0 };
u8 position; unsigned char sequence{ 0 };
u32 status; unsigned char position{ 0 };
u8 cHint; unsigned int status{ 0 };
u32 chValue; unsigned char cHint{ 0 };
u32 opParam; unsigned int chValue{ 0 };
u32 symbol; unsigned int opParam{ 0 };
u32 cmdFlag; unsigned int symbol{ 0 };
ClientCard* overlayTarget; unsigned int cmdFlag{ 0 };
ClientCard* overlayTarget{ nullptr };
std::vector<ClientCard*> overlayed; std::vector<ClientCard*> overlayed;
ClientCard* equipTarget; ClientCard* equipTarget{ nullptr };
std::set<ClientCard*> equipped; std::set<ClientCard*> equipped;
std::set<ClientCard*> cardTarget; std::set<ClientCard*> cardTarget;
std::set<ClientCard*> ownerTarget; std::set<ClientCard*> ownerTarget;
std::map<int, int> counters; std::map<int, int> counters;
std::map<int, int> desc_hints; std::map<int, int> desc_hints;
wchar_t atkstring[16]; wchar_t atkstring[16]{ 0 };
wchar_t defstring[16]; wchar_t defstring[16]{ 0 };
wchar_t lvstring[16]; wchar_t lvstring[16]{ 0 };
wchar_t linkstring[16]; wchar_t linkstring[16]{ 0 };
wchar_t lscstring[16]; wchar_t lscstring[16]{ 0 };
wchar_t rscstring[16]; wchar_t rscstring[16]{ 0 };
ClientCard(); ClientCard() = default;
~ClientCard();
void SetCode(int code); void SetCode(int code);
void UpdateInfo(char* buf); void UpdateInfo(unsigned char* buf);
void ClearTarget(); void ClearTarget();
void ClearData();
static bool client_card_sort(ClientCard* c1, ClientCard* c2); static bool client_card_sort(ClientCard* c1, ClientCard* c2);
static bool deck_sort_lv(code_pointer l1, code_pointer l2); static bool deck_sort_lv(code_pointer l1, code_pointer l2);
static bool deck_sort_atk(code_pointer l1, code_pointer l2); static bool deck_sort_atk(code_pointer l1, code_pointer l2);
......
...@@ -11,31 +11,50 @@ ...@@ -11,31 +11,50 @@
namespace ygo { namespace ygo {
ClientField::ClientField() { ClientField::ClientField() {
panel = 0;
hovered_card = 0;
clicked_card = 0;
highlighting_card = 0;
menu_card = 0;
hovered_controler = 0;
hovered_location = 0;
hovered_sequence = 0;
selectable_field = 0;
selected_field = 0;
deck_act = false;
grave_act = false;
remove_act = false;
extra_act = false;
pzone_act[0] = false;
pzone_act[1] = false;
conti_act = false;
deck_reversed = false;
conti_selecting = false;
cant_check_grave = false;
for(int p = 0; p < 2; ++p) { for(int p = 0; p < 2; ++p) {
mzone[p].resize(7, 0); mzone[p].resize(7, 0);
szone[p].resize(8, 0); szone[p].resize(8, 0);
} }
rnd.reset(std::random_device()()); rnd.reset((uint_fast32_t)std::random_device()());
}
ClientField::~ClientField() {
for (int i = 0; i < 2; ++i) {
for (auto card : deck[i]) {
delete card;
}
deck[i].clear();
for (auto card : hand[i]) {
delete card;
}
hand[i].clear();
for (auto card : mzone[i]) {
if (card)
delete card;
card = nullptr;
}
for (auto card : szone[i]) {
if (card)
delete card;
card = nullptr;
}
for (auto card : grave[i]) {
delete card;
}
grave[i].clear();
for (auto card : remove[i]) {
delete card;
}
remove[i].clear();
for (auto card : extra[i]) {
delete card;
}
extra[i].clear();
}
for (auto card : overlay_cards) {
delete card;
}
overlay_cards.clear();
} }
void ClientField::Clear() { void ClientField::Clear() {
for(int i = 0; i < 2; ++i) { for(int i = 0; i < 2; ++i) {
...@@ -303,12 +322,13 @@ ClientCard* ClientField::RemoveCard(int controler, int location, int sequence) { ...@@ -303,12 +322,13 @@ ClientCard* ClientField::RemoveCard(int controler, int location, int sequence) {
pcard->location = 0; pcard->location = 0;
return pcard; return pcard;
} }
void ClientField::UpdateCard(int controler, int location, int sequence, char* data) { void ClientField::UpdateCard(int controler, int location, int sequence, unsigned char* data) {
ClientCard* pcard = GetCard(controler, location, sequence); ClientCard* pcard = GetCard(controler, location, sequence);
if(pcard) int len = BufferIO::ReadInt32(data);
pcard->UpdateInfo(data + 4); if (pcard && len > LEN_HEADER)
pcard->UpdateInfo(data);
} }
void ClientField::UpdateFieldCard(int controler, int location, char* data) { void ClientField::UpdateFieldCard(int controler, int location, unsigned char* data) {
std::vector<ClientCard*>* lst = 0; std::vector<ClientCard*>* lst = 0;
switch(location) { switch(location) {
case LOCATION_DECK: case LOCATION_DECK:
...@@ -338,7 +358,7 @@ void ClientField::UpdateFieldCard(int controler, int location, char* data) { ...@@ -338,7 +358,7 @@ void ClientField::UpdateFieldCard(int controler, int location, char* data) {
int len; int len;
for(auto cit = lst->begin(); cit != lst->end(); ++cit) { for(auto cit = lst->begin(); cit != lst->end(); ++cit) {
len = BufferIO::ReadInt32(data); len = BufferIO::ReadInt32(data);
if(len > 8) if(len > LEN_HEADER)
(*cit)->UpdateInfo(data); (*cit)->UpdateInfo(data);
data += len - 4; data += len - 4;
} }
...@@ -595,11 +615,11 @@ void ClientField::ShowLocationCard() { ...@@ -595,11 +615,11 @@ void ClientField::ShowLocationCard() {
mainGame->stDisplayPos[i]->setBackgroundColor(0xffffffff); mainGame->stDisplayPos[i]->setBackgroundColor(0xffffffff);
} else if(display_cards[i]->location == LOCATION_EXTRA || display_cards[i]->location == LOCATION_REMOVED) { } else if(display_cards[i]->location == LOCATION_EXTRA || display_cards[i]->location == LOCATION_REMOVED) {
if(display_cards[i]->position & POS_FACEDOWN) if(display_cards[i]->position & POS_FACEDOWN)
mainGame->stCardPos[i]->setOverrideColor(0xff0000ff); mainGame->stDisplayPos[i]->setOverrideColor(0xff0000ff);
if(display_cards[i]->controler) if(display_cards[i]->controler)
mainGame->stCardPos[i]->setBackgroundColor(0xffd0d0d0); mainGame->stDisplayPos[i]->setBackgroundColor(0xffd0d0d0);
else else
mainGame->stCardPos[i]->setBackgroundColor(0xffffffff); mainGame->stDisplayPos[i]->setBackgroundColor(0xffffffff);
} else { } else {
if(display_cards[i]->controler) if(display_cards[i]->controler)
mainGame->stDisplayPos[i]->setBackgroundColor(0xffd0d0d0); mainGame->stDisplayPos[i]->setBackgroundColor(0xffd0d0d0);
...@@ -848,6 +868,9 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir ...@@ -848,6 +868,9 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir
int sequence = pcard->sequence; int sequence = pcard->sequence;
int location = pcard->location; int location = pcard->location;
int rule = (mainGame->dInfo.duel_rule >= 4) ? 1 : 0; int rule = (mainGame->dInfo.duel_rule >= 4) ? 1 : 0;
const float overlay_buttom = 0.0f;
const float material_height = 0.003f;
const float mzone_buttom = 0.020f;
switch (location) { switch (location) {
case LOCATION_DECK: { case LOCATION_DECK: {
t->X = (matManager.vFieldDeck[controler][0].Pos.X + matManager.vFieldDeck[controler][1].Pos.X) / 2; t->X = (matManager.vFieldDeck[controler][0].Pos.X + matManager.vFieldDeck[controler][1].Pos.X) / 2;
...@@ -927,7 +950,7 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir ...@@ -927,7 +950,7 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir
case LOCATION_MZONE: { case LOCATION_MZONE: {
t->X = (matManager.vFieldMzone[controler][sequence][0].Pos.X + matManager.vFieldMzone[controler][sequence][1].Pos.X) / 2; t->X = (matManager.vFieldMzone[controler][sequence][0].Pos.X + matManager.vFieldMzone[controler][sequence][1].Pos.X) / 2;
t->Y = (matManager.vFieldMzone[controler][sequence][0].Pos.Y + matManager.vFieldMzone[controler][sequence][2].Pos.Y) / 2; t->Y = (matManager.vFieldMzone[controler][sequence][0].Pos.Y + matManager.vFieldMzone[controler][sequence][2].Pos.Y) / 2;
t->Z = 0.01f; t->Z = mzone_buttom;
if (controler == 0) { if (controler == 0) {
if (pcard->position & POS_DEFENSE) { if (pcard->position & POS_DEFENSE) {
r->X = 0.0f; r->X = 0.0f;
...@@ -1040,21 +1063,22 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir ...@@ -1040,21 +1063,22 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir
break; break;
} }
case LOCATION_OVERLAY: { case LOCATION_OVERLAY: {
if (pcard->overlayTarget->location != 0x4) { if (pcard->overlayTarget->location != LOCATION_MZONE) {
return; return;
} }
int oseq = pcard->overlayTarget->sequence; int oseq = pcard->overlayTarget->sequence;
int mseq = (sequence < MAX_LAYER_COUNT) ? sequence : (MAX_LAYER_COUNT - 1);
if (pcard->overlayTarget->controler == 0) { if (pcard->overlayTarget->controler == 0) {
t->X = (matManager.vFieldMzone[0][oseq][0].Pos.X + matManager.vFieldMzone[0][oseq][1].Pos.X) / 2 - 0.12f + 0.06f * sequence; t->X = (matManager.vFieldMzone[0][oseq][0].Pos.X + matManager.vFieldMzone[0][oseq][1].Pos.X) / 2 - 0.12f + 0.06f * mseq;
t->Y = (matManager.vFieldMzone[0][oseq][0].Pos.Y + matManager.vFieldMzone[0][oseq][2].Pos.Y) / 2 + 0.05f; t->Y = (matManager.vFieldMzone[0][oseq][0].Pos.Y + matManager.vFieldMzone[0][oseq][2].Pos.Y) / 2 + 0.05f;
t->Z = 0.005f + pcard->sequence * 0.0001f; t->Z = overlay_buttom + mseq * material_height;
r->X = 0.0f; r->X = 0.0f;
r->Y = 0.0f; r->Y = 0.0f;
r->Z = 0.0f; r->Z = 0.0f;
} else { } else {
t->X = (matManager.vFieldMzone[1][oseq][0].Pos.X + matManager.vFieldMzone[1][oseq][1].Pos.X) / 2 + 0.12f - 0.06f * sequence; t->X = (matManager.vFieldMzone[1][oseq][0].Pos.X + matManager.vFieldMzone[1][oseq][1].Pos.X) / 2 + 0.12f - 0.06f * mseq;
t->Y = (matManager.vFieldMzone[1][oseq][0].Pos.Y + matManager.vFieldMzone[1][oseq][2].Pos.Y) / 2 - 0.05f; t->Y = (matManager.vFieldMzone[1][oseq][0].Pos.Y + matManager.vFieldMzone[1][oseq][2].Pos.Y) / 2 - 0.05f;
t->Z = 0.005f + pcard->sequence * 0.0001f; t->Z = overlay_buttom + mseq * material_height;
r->X = 0.0f; r->X = 0.0f;
r->Y = 0.0f; r->Y = 0.0f;
r->Z = 3.1415926f; r->Z = 3.1415926f;
......
...@@ -13,13 +13,13 @@ class ClientCard; ...@@ -13,13 +13,13 @@ class ClientCard;
struct ChainInfo { struct ChainInfo {
irr::core::vector3df chain_pos; irr::core::vector3df chain_pos;
ClientCard* chain_card; ClientCard* chain_card{ nullptr };
int code; int code{ 0 };
int desc; int desc{ 0 };
int controler; int controler{ 0 };
int location; int location{ 0 };
int sequence; int sequence{ 0 };
bool solved; bool solved{ false };
std::set<ClientCard*> target; std::set<ClientCard*> target;
}; };
...@@ -33,6 +33,7 @@ public: ...@@ -33,6 +33,7 @@ public:
std::vector<ClientCard*> remove[2]; std::vector<ClientCard*> remove[2];
std::vector<ClientCard*> extra[2]; std::vector<ClientCard*> extra[2];
std::set<ClientCard*> overlay_cards; std::set<ClientCard*> overlay_cards;
std::vector<ClientCard*> summonable_cards; std::vector<ClientCard*> summonable_cards;
std::vector<ClientCard*> spsummonable_cards; std::vector<ClientCard*> spsummonable_cards;
std::vector<ClientCard*> msetable_cards; std::vector<ClientCard*> msetable_cards;
...@@ -45,25 +46,25 @@ public: ...@@ -45,25 +46,25 @@ public:
std::vector<int> select_options; std::vector<int> select_options;
std::vector<int> select_options_index; std::vector<int> select_options_index;
std::vector<ChainInfo> chains; std::vector<ChainInfo> chains;
int extra_p_count[2]; int extra_p_count[2]{ 0 };
size_t selected_option; size_t selected_option{ 0 };
ClientCard* attacker; ClientCard* attacker{ nullptr };
ClientCard* attack_target; ClientCard* attack_target{ nullptr };
unsigned int disabled_field; unsigned int disabled_field{ 0 };
unsigned int selectable_field; unsigned int selectable_field{ 0 };
unsigned int selected_field; unsigned int selected_field{ 0 };
int select_min; int select_min{ 0 };
int select_max; int select_max{ 0 };
int must_select_count; int must_select_count{ 0 };
int select_sumval; int select_sumval{ 0 };
int select_mode; int select_mode{ 0 };
bool select_cancelable; bool select_cancelable{ false };
bool select_panalmode; bool select_panalmode{ false };
bool select_ready; bool select_ready{ false };
int announce_count; int announce_count{ 0 };
int select_counter_count; int select_counter_count{ 0 };
int select_counter_type; int select_counter_type{ 0 };
std::vector<ClientCard*> selectable_cards; std::vector<ClientCard*> selectable_cards;
std::vector<ClientCard*> selected_cards; std::vector<ClientCard*> selected_cards;
std::set<ClientCard*> selectsum_cards; std::set<ClientCard*> selectsum_cards;
...@@ -72,28 +73,29 @@ public: ...@@ -72,28 +73,29 @@ public:
std::vector<ClientCard*> display_cards; std::vector<ClientCard*> display_cards;
std::vector<int> sort_list; std::vector<int> sort_list;
std::map<int, int> player_desc_hints[2]; std::map<int, int> player_desc_hints[2];
bool grave_act; bool grave_act{ false };
bool remove_act; bool remove_act{ false };
bool deck_act; bool deck_act{ false };
bool extra_act; bool extra_act{ false };
bool pzone_act[2]; bool pzone_act[2]{ false };
bool conti_act; bool conti_act{ false };
bool chain_forced; bool chain_forced{ false };
ChainInfo current_chain; ChainInfo current_chain;
bool last_chain; bool last_chain{ false };
bool deck_reversed; bool deck_reversed{ false };
bool conti_selecting; bool conti_selecting{ false };
bool cant_check_grave; bool cant_check_grave{ false };
mt19937 rnd; mt19937 rnd;
ClientField(); ClientField();
~ClientField();
void Clear(); void Clear();
void Initial(int player, int deckc, int extrac); void Initial(int player, int deckc, int extrac);
ClientCard* GetCard(int controler, int location, int sequence, int sub_seq = 0); ClientCard* GetCard(int controler, int location, int sequence, int sub_seq = 0);
void AddCard(ClientCard* pcard, int controler, int location, int sequence); void AddCard(ClientCard* pcard, int controler, int location, int sequence);
ClientCard* RemoveCard(int controler, int location, int sequence); ClientCard* RemoveCard(int controler, int location, int sequence);
void UpdateCard(int controler, int location, int sequence, char* data); void UpdateCard(int controler, int location, int sequence, unsigned char* data);
void UpdateFieldCard(int controler, int location, char* data); void UpdateFieldCard(int controler, int location, unsigned char* data);
void ClearCommandFlag(); void ClearCommandFlag();
void ClearSelect(); void ClearSelect();
void ClearChainSelect(); void ClearChainSelect();
...@@ -121,21 +123,21 @@ public: ...@@ -121,21 +123,21 @@ public:
void UpdateDeclarableList(); void UpdateDeclarableList();
irr::gui::IGUIElement* panel; irr::gui::IGUIElement* panel{ nullptr };
std::vector<int> ancard; std::vector<int> ancard;
int hovered_controler; int hovered_controler{ 0 };
int hovered_location; int hovered_location{ 0 };
size_t hovered_sequence; size_t hovered_sequence{ 0 };
int command_controler; int command_controler{ 0 };
int command_location; int command_location{ 0 };
size_t command_sequence; size_t command_sequence{ 0 };
ClientCard* hovered_card; ClientCard* hovered_card{ nullptr };
int hovered_player; int hovered_player{ 0 };
ClientCard* clicked_card; ClientCard* clicked_card{ nullptr };
ClientCard* command_card; ClientCard* command_card{ nullptr };
ClientCard* highlighting_card; ClientCard* highlighting_card{ nullptr };
ClientCard* menu_card; ClientCard* menu_card{ nullptr };
int list_command; int list_command{ 0 };
virtual bool OnEvent(const irr::SEvent& event); virtual bool OnEvent(const irr::SEvent& event);
virtual bool OnCommonEvent(const irr::SEvent& event); virtual bool OnCommonEvent(const irr::SEvent& event);
......
...@@ -7,8 +7,8 @@ ...@@ -7,8 +7,8 @@
#define IRR_COMPILE_WITH_DX9_DEV_PACK #define IRR_COMPILE_WITH_DX9_DEV_PACK
#ifdef _WIN32 #ifdef _WIN32
#include <WinSock2.h>
#define NOMINMAX #define NOMINMAX
#include <WinSock2.h>
#include <windows.h> #include <windows.h>
#include <ws2tcpip.h> #include <ws2tcpip.h>
...@@ -69,7 +69,6 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) { ...@@ -69,7 +69,6 @@ inline int myswprintf(wchar_t(&buf)[N], const wchar_t* fmt, TR... args) {
#include <iostream> #include <iostream>
#include <stdio.h> #include <stdio.h>
#include <stdlib.h> #include <stdlib.h>
#include <memory.h>
#include <time.h> #include <time.h>
#include <thread> #include <thread>
#include <mutex> #include <mutex>
...@@ -87,6 +86,8 @@ using namespace video; ...@@ -87,6 +86,8 @@ using namespace video;
using namespace io; using namespace io;
using namespace gui; using namespace gui;
typedef int BOOL;
extern const unsigned short PRO_VERSION; extern const unsigned short PRO_VERSION;
extern int enable_log; extern int enable_log;
extern bool exit_on_return; extern bool exit_on_return;
......
...@@ -147,12 +147,25 @@ bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt) { ...@@ -147,12 +147,25 @@ bool DataManager::Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt) {
spmemvfs_env_fini(); spmemvfs_env_fini();
return false; return false;
} }
bool DataManager::GetData(int code, CardData* pData) { bool DataManager::GetData(unsigned int code, CardData* pData) {
auto cdit = _datas.find(code); auto cdit = _datas.find(code);
if(cdit == _datas.end()) if(cdit == _datas.end())
return false; return false;
if(pData) auto data = cdit->second;
*pData = *((CardData*)&cdit->second); if (pData) {
pData->code = data.code;
pData->alias = data.alias;
pData->setcode = data.setcode;
pData->type = data.type;
pData->level = data.level;
pData->attribute = data.attribute;
pData->race = data.race;
pData->attack = data.attack;
pData->defense = data.defense;
pData->lscale = data.lscale;
pData->rscale = data.rscale;
pData->link_marker = data.link_marker;
}
return true; return true;
} }
code_pointer DataManager::GetCodePointer(int code) { code_pointer DataManager::GetCodePointer(int code) {
...@@ -346,9 +359,9 @@ const wchar_t* DataManager::FormatLinkMarker(int link_marker) { ...@@ -346,9 +359,9 @@ const wchar_t* DataManager::FormatLinkMarker(int link_marker) {
BufferIO::CopyWStrRef(L"[\u2198]", p, 4); BufferIO::CopyWStrRef(L"[\u2198]", p, 4);
return lmBuffer; return lmBuffer;
} }
int DataManager::CardReader(int code, void* pData) { uint32 DataManager::CardReader(uint32 code, card_data* pData) {
if(!dataManager.GetData(code, (CardData*)pData)) if (!dataManager.GetData(code, pData))
memset(pData, 0, sizeof(CardData)); pData->clear();
return 0; return 0;
} }
byte* DataManager::ScriptReaderEx(const char* script_name, int* slen) { byte* DataManager::ScriptReaderEx(const char* script_name, int* slen) {
......
...@@ -11,13 +11,13 @@ namespace ygo { ...@@ -11,13 +11,13 @@ namespace ygo {
class DataManager { class DataManager {
public: public:
DataManager(): _datas(8192), _strings(8192) {} DataManager(): _datas(16384), _strings(16384) {}
bool LoadDB(const wchar_t* wfile); bool LoadDB(const wchar_t* wfile);
bool LoadStrings(const char* file); bool LoadStrings(const char* file);
bool LoadStrings(IReadFile* reader); bool LoadStrings(IReadFile* reader);
void ReadStringConfLine(const char* linebuf); void ReadStringConfLine(const char* linebuf);
bool Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt = 0); bool Error(spmemvfs_db_t* pDB, sqlite3_stmt* pStmt = 0);
bool GetData(int code, CardData* pData); bool GetData(unsigned int code, CardData* pData);
code_pointer GetCodePointer(int code); code_pointer GetCodePointer(int code);
bool GetString(int code, CardString* pStr); bool GetString(int code, CardString* pStr);
const wchar_t* GetName(int code); const wchar_t* GetName(int code);
...@@ -53,7 +53,7 @@ public: ...@@ -53,7 +53,7 @@ public:
static byte scriptBuffer[0x20000]; static byte scriptBuffer[0x20000];
static const wchar_t* unknown_string; static const wchar_t* unknown_string;
static int CardReader(int, void*); static uint32 CardReader(uint32, card_data*);
static byte* ScriptReaderEx(const char* script_name, int* slen); static byte* ScriptReaderEx(const char* script_name, int* slen);
static byte* ScriptReader(const char* script_name, int* slen); static byte* ScriptReader(const char* script_name, int* slen);
static IFileSystem* FileSystem; static IFileSystem* FileSystem;
......
...@@ -79,7 +79,7 @@ void DeckBuilder::Initialize() { ...@@ -79,7 +79,7 @@ void DeckBuilder::Initialize() {
mainGame->btnSideReload->setVisible(false); mainGame->btnSideReload->setVisible(false);
filterList = &deckManager._lfList[mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : deckManager._lfList.size() - 1].content; filterList = &deckManager._lfList[mainGame->gameConf.use_lflist ? mainGame->gameConf.default_lflist : deckManager._lfList.size() - 1].content;
ClearSearch(); ClearSearch();
rnd.reset((unsigned int)time(nullptr)); rnd.reset((uint_fast32_t)time(nullptr));
mouse_pos.set(0, 0); mouse_pos.set(0, 0);
hovered_code = 0; hovered_code = 0;
hovered_pos = 0; hovered_pos = 0;
...@@ -652,8 +652,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) { ...@@ -652,8 +652,8 @@ bool DeckBuilder::OnEvent(const irr::SEvent& event) {
break; break;
} }
mainGame->ClearCardInfo(); mainGame->ClearCardInfo();
char deckbuf[1024]; unsigned char deckbuf[1024];
char* pdeck = deckbuf; auto pdeck = deckbuf;
BufferIO::WriteInt32(pdeck, deckManager.current_deck.main.size() + deckManager.current_deck.extra.size()); BufferIO::WriteInt32(pdeck, deckManager.current_deck.main.size() + deckManager.current_deck.extra.size());
BufferIO::WriteInt32(pdeck, deckManager.current_deck.side.size()); BufferIO::WriteInt32(pdeck, deckManager.current_deck.side.size());
for(size_t i = 0; i < deckManager.current_deck.main.size(); ++i) for(size_t i = 0; i < deckManager.current_deck.main.size(); ++i)
......
...@@ -318,8 +318,21 @@ void Game::DrawCards() { ...@@ -318,8 +318,21 @@ void Game::DrawCards() {
for(auto it = dField.extra[p].begin(); it != dField.extra[p].end(); ++it) for(auto it = dField.extra[p].begin(); it != dField.extra[p].end(); ++it)
DrawCard(*it); DrawCard(*it);
} }
for(auto cit = dField.overlay_cards.begin(); cit != dField.overlay_cards.end(); ++cit) for (auto cit = dField.overlay_cards.begin(); cit != dField.overlay_cards.end(); ++cit) {
DrawCard(*cit); auto pcard = (*cit);
auto olcard = pcard->overlayTarget;
if (pcard->aniFrame) {
DrawCard(pcard);
}
else if (olcard && olcard->location == LOCATION_MZONE) {
if (pcard->sequence < MAX_LAYER_COUNT) {
DrawCard(pcard);
}
}
else {
DrawCard(pcard);
}
}
} }
void Game::DrawCard(ClientCard* pcard) { void Game::DrawCard(ClientCard* pcard) {
if(pcard->aniFrame) { if(pcard->aniFrame) {
......
...@@ -19,14 +19,14 @@ unsigned char DuelClient::selftype = 0; ...@@ -19,14 +19,14 @@ unsigned char DuelClient::selftype = 0;
bool DuelClient::is_host = false; bool DuelClient::is_host = false;
event_base* DuelClient::client_base = 0; event_base* DuelClient::client_base = 0;
bufferevent* DuelClient::client_bev = 0; bufferevent* DuelClient::client_bev = 0;
char DuelClient::duel_client_read[0x2000]; unsigned char DuelClient::duel_client_read[0x2000];
char DuelClient::duel_client_write[0x2000]; unsigned char DuelClient::duel_client_write[0x2000];
bool DuelClient::is_closing = false; bool DuelClient::is_closing = false;
bool DuelClient::is_swapping = false; bool DuelClient::is_swapping = false;
int DuelClient::select_hint = 0; int DuelClient::select_hint = 0;
int DuelClient::select_unselect_hint = 0; int DuelClient::select_unselect_hint = 0;
int DuelClient::last_select_hint = 0; int DuelClient::last_select_hint = 0;
char DuelClient::last_successful_msg[0x2000]; unsigned char DuelClient::last_successful_msg[0x2000];
unsigned int DuelClient::last_successful_msg_length = 0; unsigned int DuelClient::last_successful_msg_length = 0;
wchar_t DuelClient::event_string[256]; wchar_t DuelClient::event_string[256];
mt19937 DuelClient::rnd; mt19937 DuelClient::rnd;
...@@ -58,7 +58,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g ...@@ -58,7 +58,7 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
return false; return false;
} }
connect_state = 0x1; connect_state = 0x1;
rnd.reset((unsigned int)time(nullptr)); rnd.reset((uint_fast32_t)std::random_device()());
if(!create_game) { if(!create_game) {
timeval timeout = {5, 0}; timeval timeout = {5, 0};
event* resp_event = event_new(client_base, 0, EV_TIMEOUT, ConnectTimeout, 0); event* resp_event = event_new(client_base, 0, EV_TIMEOUT, ConnectTimeout, 0);
...@@ -233,8 +233,8 @@ int DuelClient::ClientThread() { ...@@ -233,8 +233,8 @@ int DuelClient::ClientThread() {
connect_state = 0; connect_state = 0;
return 0; return 0;
} }
void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { void DuelClient::HandleSTOCPacketLan(unsigned char* data, unsigned int len) {
char* pdata = data; unsigned char* pdata = data;
unsigned char pktType = BufferIO::ReadUInt8(pdata); unsigned char pktType = BufferIO::ReadUInt8(pdata);
switch(pktType) { switch(pktType) {
case STOC_GAME_MSG: { case STOC_GAME_MSG: {
...@@ -611,7 +611,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -611,7 +611,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->device->setEventReceiver(&mainGame->dField); mainGame->device->setEventReceiver(&mainGame->dField);
if(!mainGame->dInfo.isTag) { if(!mainGame->dInfo.isTag) {
if(selftype > 1) { if(selftype > 1) {
mainGame->dInfo.player_type = 7; mainGame->dInfo.player_type = NETPLAYER_TYPE_OBSERVER;
mainGame->btnLeaveGame->setText(dataManager.GetSysString(1350)); mainGame->btnLeaveGame->setText(dataManager.GetSysString(1350));
mainGame->btnLeaveGame->setVisible(true); mainGame->btnLeaveGame->setVisible(true);
mainGame->btnSpectatorSwap->setVisible(true); mainGame->btnSpectatorSwap->setVisible(true);
...@@ -689,7 +689,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -689,7 +689,7 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
if(mainGame->dInfo.player_type < 7) if(mainGame->dInfo.player_type < 7)
mainGame->btnLeaveGame->setVisible(false); mainGame->btnLeaveGame->setVisible(false);
mainGame->CloseGameButtons(); mainGame->CloseGameButtons();
char* prep = pdata; auto prep = pdata;
Replay new_replay; Replay new_replay;
memcpy(&new_replay.pheader, prep, sizeof(ReplayHeader)); memcpy(&new_replay.pheader, prep, sizeof(ReplayHeader));
time_t starttime; time_t starttime;
...@@ -882,8 +882,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -882,8 +882,9 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
} }
} }
} }
int DuelClient::ClientAnalyze(char * msg, unsigned int len) { // Analyze STOC_GAME_MSG packet
char* pbuf = msg; int DuelClient::ClientAnalyze(unsigned char* msg, unsigned int len) {
unsigned char* pbuf = msg;
wchar_t textBuffer[256]; wchar_t textBuffer[256];
mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf); mainGame->dInfo.curMsg = BufferIO::ReadUInt8(pbuf);
if(mainGame->dInfo.curMsg != MSG_RETRY) { if(mainGame->dInfo.curMsg != MSG_RETRY) {
...@@ -918,7 +919,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -918,7 +919,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
switch(mainGame->dInfo.curMsg) { switch(mainGame->dInfo.curMsg) {
case MSG_RETRY: { case MSG_RETRY: {
if(last_successful_msg_length) { if(last_successful_msg_length) {
char* p = last_successful_msg; auto p = last_successful_msg;
auto last_msg = BufferIO::ReadUInt8(p); auto last_msg = BufferIO::ReadUInt8(p);
int err_desc = 1421; int err_desc = 1421;
switch(last_msg) { switch(last_msg) {
...@@ -2524,7 +2525,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2524,7 +2525,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
int appear = mainGame->gameConf.quick_animation ? 12 : 20; int appear = mainGame->gameConf.quick_animation ? 12 : 20;
if (pl == 0) { if (pl == 0) {
ClientCard* pcard = new ClientCard(); ClientCard* pcard = new ClientCard;
pcard->position = cp; pcard->position = cp;
pcard->SetCode(code); pcard->SetCode(code);
if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) { if(!mainGame->dInfo.isReplay || !mainGame->dInfo.isReplaySkiping) {
...@@ -2650,7 +2651,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -2650,7 +2651,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
pcard->overlayTarget = olcard; pcard->overlayTarget = olcard;
pcard->location = LOCATION_OVERLAY; pcard->location = LOCATION_OVERLAY;
pcard->sequence = olcard->overlayed.size() - 1; pcard->sequence = olcard->overlayed.size() - 1;
if (olcard->location == 0x4) { if (olcard->location == LOCATION_MZONE) {
mainGame->gMutex.lock(); mainGame->gMutex.lock();
mainGame->dField.MoveCard(pcard, 10); mainGame->dField.MoveCard(pcard, 10);
if (pl == 0x2) if (pl == 0x2)
...@@ -3743,7 +3744,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3743,7 +3744,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
} else { } else {
while(mainGame->dField.deck[player].size() < mcount) { while(mainGame->dField.deck[player].size() < mcount) {
ClientCard* ccard = new ClientCard(); ClientCard* ccard = new ClientCard;
ccard->controler = player; ccard->controler = player;
ccard->location = LOCATION_DECK; ccard->location = LOCATION_DECK;
ccard->sequence = mainGame->dField.deck[player].size(); ccard->sequence = mainGame->dField.deck[player].size();
...@@ -3758,7 +3759,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3758,7 +3759,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
} else { } else {
while(mainGame->dField.hand[player].size() < hcount) { while(mainGame->dField.hand[player].size() < hcount) {
ClientCard* ccard = new ClientCard(); ClientCard* ccard = new ClientCard;
ccard->controler = player; ccard->controler = player;
ccard->location = LOCATION_HAND; ccard->location = LOCATION_HAND;
ccard->sequence = mainGame->dField.hand[player].size(); ccard->sequence = mainGame->dField.hand[player].size();
...@@ -3773,7 +3774,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) { ...@@ -3773,7 +3774,7 @@ int DuelClient::ClientAnalyze(char * msg, unsigned int len) {
} }
} else { } else {
while(mainGame->dField.extra[player].size() < ecount) { while(mainGame->dField.extra[player].size() < ecount) {
ClientCard* ccard = new ClientCard(); ClientCard* ccard = new ClientCard;
ccard->controler = player; ccard->controler = player;
ccard->location = LOCATION_EXTRA; ccard->location = LOCATION_EXTRA;
ccard->sequence = mainGame->dField.extra[player].size(); ccard->sequence = mainGame->dField.extra[player].size();
......
...@@ -27,14 +27,14 @@ private: ...@@ -27,14 +27,14 @@ private:
static bool is_host; static bool is_host;
static event_base* client_base; static event_base* client_base;
static bufferevent* client_bev; static bufferevent* client_bev;
static char duel_client_read[0x2000]; static unsigned char duel_client_read[0x2000];
static char duel_client_write[0x2000]; static unsigned char duel_client_write[0x2000];
static bool is_closing; static bool is_closing;
static bool is_swapping; static bool is_swapping;
static int select_hint; static int select_hint;
static int select_unselect_hint; static int select_unselect_hint;
static int last_select_hint; static int last_select_hint;
static char last_successful_msg[0x2000]; static unsigned char last_successful_msg[0x2000];
static unsigned int last_successful_msg_length; static unsigned int last_successful_msg_length;
static wchar_t event_string[256]; static wchar_t event_string[256];
static mt19937 rnd; static mt19937 rnd;
...@@ -45,28 +45,28 @@ public: ...@@ -45,28 +45,28 @@ public:
static void ClientRead(bufferevent* bev, void* ctx); static void ClientRead(bufferevent* bev, void* ctx);
static void ClientEvent(bufferevent *bev, short events, void *ctx); static void ClientEvent(bufferevent *bev, short events, void *ctx);
static int ClientThread(); static int ClientThread();
static void HandleSTOCPacketLan(char* data, unsigned int len); static void HandleSTOCPacketLan(unsigned char* data, unsigned int len);
static int ClientAnalyze(char* msg, unsigned int len); static int ClientAnalyze(unsigned char* msg, unsigned int len);
static void SwapField(); static void SwapField();
static void SetResponseI(int respI); static void SetResponseI(int respI);
static void SetResponseB(void* respB, unsigned char len); static void SetResponseB(void* respB, unsigned char len);
static void SendResponse(); static void SendResponse();
static void SendPacketToServer(unsigned char proto) { static void SendPacketToServer(unsigned char proto) {
char* p = duel_client_write; auto p = duel_client_write;
BufferIO::WriteInt16(p, 1); BufferIO::WriteInt16(p, 1);
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
bufferevent_write(client_bev, duel_client_write, 3); bufferevent_write(client_bev, duel_client_write, 3);
} }
template<typename ST> template<typename ST>
static void SendPacketToServer(unsigned char proto, ST& st) { static void SendPacketToServer(unsigned char proto, ST& st) {
char* p = duel_client_write; auto p = duel_client_write;
BufferIO::WriteInt16(p, 1 + sizeof(ST)); BufferIO::WriteInt16(p, 1 + sizeof(ST));
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
memcpy(p, &st, sizeof(ST)); memcpy(p, &st, sizeof(ST));
bufferevent_write(client_bev, duel_client_write, sizeof(ST) + 3); bufferevent_write(client_bev, duel_client_write, sizeof(ST) + 3);
} }
static void SendBufferToServer(unsigned char proto, void* buffer, size_t len) { static void SendBufferToServer(unsigned char proto, void* buffer, size_t len) {
char* p = duel_client_write; auto p = duel_client_write;
BufferIO::WriteInt16(p, 1 + len); BufferIO::WriteInt16(p, 1 + len);
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
memcpy(p, buffer, len); memcpy(p, buffer, len);
......
...@@ -2232,25 +2232,62 @@ void ClientField::GetHoverField(int x, int y) { ...@@ -2232,25 +2232,62 @@ void ClientField::GetHoverField(int x, int y) {
hovered_sequence = sequence; hovered_sequence = sequence;
} else if(boardy >= matManager.vFieldMzone[0][5][0].Pos.Y && boardy <= matManager.vFieldMzone[0][5][2].Pos.Y) { } else if(boardy >= matManager.vFieldMzone[0][5][0].Pos.Y && boardy <= matManager.vFieldMzone[0][5][2].Pos.Y) {
if(sequence == 1) { if(sequence == 1) {
if(!mzone[1][6]) { if (mzone[0][5]) {
hovered_controler = 0; hovered_controler = 0;
hovered_location = LOCATION_MZONE; hovered_location = LOCATION_MZONE;
hovered_sequence = 5; hovered_sequence = 5;
} else { }
else if(mzone[1][6]) {
hovered_controler = 1; hovered_controler = 1;
hovered_location = LOCATION_MZONE; hovered_location = LOCATION_MZONE;
hovered_sequence = 6; hovered_sequence = 6;
} }
} else if(sequence == 3) { else if((mainGame->dInfo.curMsg == MSG_SELECT_PLACE || mainGame->dInfo.curMsg == MSG_SELECT_DISFIELD)) {
if(!mzone[1][5]) { if (mainGame->dField.selectable_field & (0x1 << (16 + 6))) {
hovered_controler = 1;
hovered_location = LOCATION_MZONE;
hovered_sequence = 6;
}
else {
hovered_controler = 0;
hovered_location = LOCATION_MZONE;
hovered_sequence = 5;
}
}
else{
hovered_controler = 0;
hovered_location = LOCATION_MZONE;
hovered_sequence = 5;
}
}
else if(sequence == 3) {
if (mzone[0][6]) {
hovered_controler = 0; hovered_controler = 0;
hovered_location = LOCATION_MZONE; hovered_location = LOCATION_MZONE;
hovered_sequence = 6; hovered_sequence = 6;
} else { }
else if (mzone[1][5]) {
hovered_controler = 1; hovered_controler = 1;
hovered_location = LOCATION_MZONE; hovered_location = LOCATION_MZONE;
hovered_sequence = 5; hovered_sequence = 5;
} }
else if ((mainGame->dInfo.curMsg == MSG_SELECT_PLACE || mainGame->dInfo.curMsg == MSG_SELECT_DISFIELD)) {
if (mainGame->dField.selectable_field & (0x1 << (16 + 5))) {
hovered_controler = 1;
hovered_location = LOCATION_MZONE;
hovered_sequence = 5;
}
else {
hovered_controler = 0;
hovered_location = LOCATION_MZONE;
hovered_sequence = 6;
}
}
else {
hovered_controler = 0;
hovered_location = LOCATION_MZONE;
hovered_sequence = 6;
}
} }
} else if(boardy >= matManager.vFieldMzone[1][0][2].Pos.Y && boardy <= matManager.vFieldMzone[1][0][0].Pos.Y) { } else if(boardy >= matManager.vFieldMzone[1][0][2].Pos.Y && boardy <= matManager.vFieldMzone[1][0][0].Pos.Y) {
hovered_controler = 1; hovered_controler = 1;
......
...@@ -16,8 +16,39 @@ namespace ygo { ...@@ -16,8 +16,39 @@ namespace ygo {
Game* mainGame; Game* mainGame;
void DuelInfo::Clear() {
isStarted = false;
isFinished = false;
isReplay = false;
isReplaySkiping = false;
isFirst = false;
isTag = false;
isSingleMode = false;
is_shuffling = false;
tag_player[0] = false;
tag_player[1] = false;
isReplaySwapped = false;
lp[0] = 0;
lp[1] = 0;
start_lp = 0;
duel_rule = 0;
turn = 0;
curMsg = 0;
hostname[0] = 0;
clientname[0] = 0;
hostname_tag[0] = 0;
clientname_tag[0] = 0;
strLP[0][0] = 0;
strLP[1][0] = 0;
vic_string = 0;
player_type = 0;
time_player = 0;
time_limit = 0;
time_left[0] = 0;
time_left[1] = 0;
}
bool Game::Initialize() { bool Game::Initialize() {
srand(time(0));
LoadConfig(); LoadConfig();
irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters(); irr::SIrrlichtCreationParameters params = irr::SIrrlichtCreationParameters();
params.AntiAlias = gameConf.antialias; params.AntiAlias = gameConf.antialias;
...@@ -50,8 +81,9 @@ bool Game::Initialize() { ...@@ -50,8 +81,9 @@ bool Game::Initialize() {
is_building = false; is_building = false;
menuHandler.prev_operation = 0; menuHandler.prev_operation = 0;
menuHandler.prev_sel = -1; menuHandler.prev_sel = -1;
memset(&dInfo, 0, sizeof(DuelInfo)); for (auto i : chatTiming) {
memset(chatTiming, 0, sizeof(chatTiming)); i = 0;
}
deckManager.LoadLFList(); deckManager.LoadLFList();
driver = device->getVideoDriver(); driver = device->getVideoDriver();
driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false); driver->setTextureCreationFlag(irr::video::ETCF_CREATE_MIP_MAPS, false);
...@@ -1542,8 +1574,7 @@ void Game::ShowCardInfo(int code, bool resize) { ...@@ -1542,8 +1574,7 @@ void Game::ShowCardInfo(int code, bool resize) {
return; return;
CardData cd; CardData cd;
wchar_t formatBuffer[256]; wchar_t formatBuffer[256];
if(!dataManager.GetData(code, &cd)) dataManager.GetData(code, &cd);
memset(&cd, 0, sizeof(CardData));
imgCard->setImage(imageManager.GetTexture(code, true)); imgCard->setImage(imageManager.GetTexture(code, true));
if(cd.alias != 0 && (cd.alias - code < CARD_ARTWORK_VERSIONS_OFFSET || code - cd.alias < CARD_ARTWORK_VERSIONS_OFFSET)) if(cd.alias != 0 && (cd.alias - code < CARD_ARTWORK_VERSIONS_OFFSET || code - cd.alias < CARD_ARTWORK_VERSIONS_OFFSET))
myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(cd.alias), cd.alias); myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(cd.alias), cd.alias);
......
...@@ -66,31 +66,33 @@ struct Config { ...@@ -66,31 +66,33 @@ struct Config {
}; };
struct DuelInfo { struct DuelInfo {
bool isStarted; bool isStarted{ false };
bool isFinished; bool isFinished{ false };
bool isReplay; bool isReplay{ false };
bool isReplaySkiping; bool isReplaySkiping{ false };
bool isFirst; bool isFirst{ false };
bool isTag; bool isTag{ false };
bool isSingleMode; bool isSingleMode{ false };
bool is_shuffling; bool is_shuffling{ false };
bool tag_player[2]; bool tag_player[2]{ false };
int lp[2]; bool isReplaySwapped{ false };
int start_lp; int lp[2]{ 0 };
int duel_rule; int start_lp{ 0 };
int turn; int duel_rule{ 0 };
short curMsg; int turn{ 0 };
wchar_t hostname[20]; short curMsg{ 0 };
wchar_t clientname[20]; wchar_t hostname[20]{ 0 };
wchar_t hostname_tag[20]; wchar_t clientname[20]{ 0 };
wchar_t clientname_tag[20]; wchar_t hostname_tag[20]{ 0 };
wchar_t strLP[2][16]; wchar_t clientname_tag[20]{ 0 };
wchar_t* vic_string; wchar_t strLP[2][16]{ 0 };
unsigned char player_type; wchar_t* vic_string{ 0 };
unsigned char time_player; unsigned char player_type{ 0 };
unsigned short time_limit; unsigned char time_player{ 0 };
unsigned short time_left[2]; unsigned short time_limit{ 0 };
bool isReplaySwapped; unsigned short time_left[2]{ 0 };
void Clear();
}; };
struct BotInfo { struct BotInfo {
...@@ -593,6 +595,8 @@ extern Game* mainGame; ...@@ -593,6 +595,8 @@ extern Game* mainGame;
} }
#define SIZE_QUERY_BUFFER 0x4000
#define CARD_IMG_WIDTH 177 #define CARD_IMG_WIDTH 177
#define CARD_IMG_HEIGHT 254 #define CARD_IMG_HEIGHT 254
#define CARD_THUMB_WIDTH 44 #define CARD_THUMB_WIDTH 44
...@@ -801,13 +805,27 @@ extern Game* mainGame; ...@@ -801,13 +805,27 @@ extern Game* mainGame;
#define BUTTON_BIG_CARD_ZOOM_OUT 382 #define BUTTON_BIG_CARD_ZOOM_OUT 382
#define BUTTON_BIG_CARD_ORIG_SIZE 383 #define BUTTON_BIG_CARD_ORIG_SIZE 383
//STOC_GAME_MSG messages
#define MSG_WAITING 3
#define MSG_START 4
#define MSG_UPDATE_DATA 6 // flag=0: clear
#define MSG_UPDATE_CARD 7 // flag=QUERY_CODE, code=0: clear
#define MSG_REQUEST_DECK 8
#define MSG_REFRESH_DECK 34
#define MSG_CARD_SELECTED 80
#define MSG_UNEQUIP 95
#define MSG_BE_CHAIN_TARGET 121
#define MSG_CREATE_RELATION 122
#define MSG_RELEASE_RELATION 123
#define AVAIL_OCG 0x1 #define AVAIL_OCG 0x1
#define AVAIL_TCG 0x2 #define AVAIL_TCG 0x2
#define AVAIL_CUSTOM 0x4 #define AVAIL_CUSTOM 0x4
#define AVAIL_SC 0x8 #define AVAIL_SC 0x8
#define AVAIL_OCGTCG (AVAIL_OCG|AVAIL_TCG) #define AVAIL_OCGTCG (AVAIL_OCG|AVAIL_TCG)
#define DEFAULT_DUEL_RULE 5 #define DEFAULT_DUEL_RULE 5
#define CARD_ARTWORK_VERSIONS_OFFSET 10 #define CARD_ARTWORK_VERSIONS_OFFSET 10
#define MAX_LAYER_COUNT 6
#endif // GAME_H #endif // GAME_H
...@@ -16,8 +16,8 @@ void UpdateDeck() { ...@@ -16,8 +16,8 @@ void UpdateDeck() {
mainGame->gameConf.lastcategory, 64); mainGame->gameConf.lastcategory, 64);
BufferIO::CopyWStr(mainGame->cbDeckSelect->getItem(mainGame->cbDeckSelect->getSelected()), BufferIO::CopyWStr(mainGame->cbDeckSelect->getItem(mainGame->cbDeckSelect->getSelected()),
mainGame->gameConf.lastdeck, 64); mainGame->gameConf.lastdeck, 64);
char deckbuf[1024]; unsigned char deckbuf[1024];
char* pdeck = deckbuf; auto pdeck = deckbuf;
BufferIO::WriteInt32(pdeck, deckManager.current_deck.main.size() + deckManager.current_deck.extra.size()); BufferIO::WriteInt32(pdeck, deckManager.current_deck.main.size() + deckManager.current_deck.extra.size());
BufferIO::WriteInt32(pdeck, deckManager.current_deck.side.size()); BufferIO::WriteInt32(pdeck, deckManager.current_deck.side.size());
for(size_t i = 0; i < deckManager.current_deck.main.size(); ++i) for(size_t i = 0; i < deckManager.current_deck.main.size(); ++i)
......
...@@ -9,8 +9,8 @@ event_base* NetServer::net_evbase = 0; ...@@ -9,8 +9,8 @@ event_base* NetServer::net_evbase = 0;
event* NetServer::broadcast_ev = 0; event* NetServer::broadcast_ev = 0;
evconnlistener* NetServer::listener = 0; evconnlistener* NetServer::listener = 0;
DuelMode* NetServer::duel_mode = 0; DuelMode* NetServer::duel_mode = 0;
char NetServer::net_server_read[0x2000]; unsigned char NetServer::net_server_read[0x2000];
char NetServer::net_server_write[0x2000]; unsigned char NetServer::net_server_write[0x2000];
unsigned short NetServer::last_sent = 0; unsigned short NetServer::last_sent = 0;
bool NetServer::StartServer(unsigned short port) { bool NetServer::StartServer(unsigned short port) {
...@@ -171,8 +171,8 @@ void NetServer::DisconnectPlayer(DuelPlayer* dp) { ...@@ -171,8 +171,8 @@ void NetServer::DisconnectPlayer(DuelPlayer* dp) {
users.erase(bit); users.erase(bit);
} }
} }
void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) { void NetServer::HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, unsigned int len) {
char* pdata = data; auto pdata = data;
unsigned char pktType = BufferIO::ReadUInt8(pdata); unsigned char pktType = BufferIO::ReadUInt8(pdata);
if((pktType != CTOS_SURRENDER) && (pktType != CTOS_CHAT) && (dp->state == 0xff || (dp->state && dp->state != pktType))) if((pktType != CTOS_SURRENDER) && (pktType != CTOS_CHAT) && (dp->state == 0xff || (dp->state && dp->state != pktType)))
return; return;
......
...@@ -18,8 +18,8 @@ private: ...@@ -18,8 +18,8 @@ private:
static event* broadcast_ev; static event* broadcast_ev;
static evconnlistener* listener; static evconnlistener* listener;
static DuelMode* duel_mode; static DuelMode* duel_mode;
static char net_server_read[0x2000]; static unsigned char net_server_read[0x2000];
static char net_server_write[0x2000]; static unsigned char net_server_write[0x2000];
static unsigned short last_sent; static unsigned short last_sent;
public: public:
...@@ -35,9 +35,9 @@ public: ...@@ -35,9 +35,9 @@ public:
static void ServerEchoEvent(bufferevent* bev, short events, void* ctx); static void ServerEchoEvent(bufferevent* bev, short events, void* ctx);
static int ServerThread(); static int ServerThread();
static void DisconnectPlayer(DuelPlayer* dp); static void DisconnectPlayer(DuelPlayer* dp);
static void HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len); static void HandleCTOSPacket(DuelPlayer* dp, unsigned char* data, unsigned int len);
static void SendPacketToPlayer(DuelPlayer* dp, unsigned char proto) { static void SendPacketToPlayer(DuelPlayer* dp, unsigned char proto) {
char* p = net_server_write; auto p = net_server_write;
BufferIO::WriteInt16(p, 1); BufferIO::WriteInt16(p, 1);
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
last_sent = 3; last_sent = 3;
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
} }
template<typename ST> template<typename ST>
static void SendPacketToPlayer(DuelPlayer* dp, unsigned char proto, ST& st) { static void SendPacketToPlayer(DuelPlayer* dp, unsigned char proto, ST& st) {
char* p = net_server_write; auto p = net_server_write;
BufferIO::WriteInt16(p, 1 + sizeof(ST)); BufferIO::WriteInt16(p, 1 + sizeof(ST));
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
memcpy(p, &st, sizeof(ST)); memcpy(p, &st, sizeof(ST));
...@@ -56,7 +56,7 @@ public: ...@@ -56,7 +56,7 @@ public:
bufferevent_write(dp->bev, net_server_write, last_sent); bufferevent_write(dp->bev, net_server_write, last_sent);
} }
static void SendBufferToPlayer(DuelPlayer* dp, unsigned char proto, void* buffer, size_t len) { static void SendBufferToPlayer(DuelPlayer* dp, unsigned char proto, void* buffer, size_t len) {
char* p = net_server_write; auto p = net_server_write;
BufferIO::WriteInt16(p, 1 + len); BufferIO::WriteInt16(p, 1 + len);
BufferIO::WriteInt8(p, proto); BufferIO::WriteInt8(p, proto);
memcpy(p, buffer, len); memcpy(p, buffer, len);
......
...@@ -12,16 +12,16 @@ ...@@ -12,16 +12,16 @@
namespace ygo { namespace ygo {
struct HostInfo { struct HostInfo {
unsigned int lflist; unsigned int lflist{ 0 };
unsigned char rule; unsigned char rule{ 0 };
unsigned char mode; unsigned char mode{ 0 };
unsigned char duel_rule; unsigned char duel_rule{ 0 };
bool no_check_deck; bool no_check_deck{ false };
bool no_shuffle_deck; bool no_shuffle_deck{ false };
unsigned int start_lp; unsigned int start_lp{ 0 };
unsigned char start_hand; unsigned char start_hand{ 0 };
unsigned char draw_count; unsigned char draw_count{ 0 };
unsigned short time_limit; unsigned short time_limit{ 0 };
}; };
struct HostPacket { struct HostPacket {
unsigned short identifier; unsigned short identifier;
...@@ -99,22 +99,17 @@ struct STOC_HS_WatchChange { ...@@ -99,22 +99,17 @@ struct STOC_HS_WatchChange {
class DuelMode; class DuelMode;
struct DuelPlayer { struct DuelPlayer {
unsigned short name[20]; unsigned short name[20]{ 0 };
DuelMode* game; DuelMode* game{ nullptr };
unsigned char type; unsigned char player_id{ 0xff };
unsigned char state; unsigned char type{ 0 };
bufferevent* bev; unsigned char state{ 0 };
DuelPlayer() { bufferevent* bev{ 0 };
game = 0;
type = 0;
state = 0;
bev = 0;
}
}; };
class DuelMode { class DuelMode {
public: public:
DuelMode(): host_player(0), pduel(0), duel_stage(0) {} DuelMode(): host_player(nullptr), pduel(0), duel_stage(0) {}
virtual ~DuelMode() {} virtual ~DuelMode() {}
virtual void Chat(DuelPlayer* dp, void* pdata, int len) {} virtual void Chat(DuelPlayer* dp, void* pdata, int len) {}
virtual void JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {} virtual void JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {}
......
...@@ -2,7 +2,6 @@ ...@@ -2,7 +2,6 @@
#define REPLAY_H #define REPLAY_H
#include "config.h" #include "config.h"
#include <time.h>
namespace ygo { namespace ygo {
...@@ -53,7 +52,7 @@ public: ...@@ -53,7 +52,7 @@ public:
static bool RenameReplay(const wchar_t* oldname, const wchar_t* newname); static bool RenameReplay(const wchar_t* oldname, const wchar_t* newname);
bool ReadNextResponse(unsigned char resp[64]); bool ReadNextResponse(unsigned char resp[64]);
void ReadName(wchar_t* data); void ReadName(wchar_t* data);
void ReadHeader(ReplayHeader& header); //void ReadHeader(ReplayHeader& header);
void ReadData(void* data, int length); void ReadData(void* data, int length);
int ReadInt32(); int ReadInt32();
short ReadInt16(); short ReadInt16();
......
This diff is collapsed.
#ifndef REPLAY_MODE_H #ifndef REPLAY_MODE_H
#define REPLAY_MODE_H #define REPLAY_MODE_H
#include "config.h" #include <stdint.h>
#include "data_manager.h" #include <vector>
#include "deck_manager.h"
#include "replay.h" #include "replay.h"
#include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
...@@ -22,6 +20,7 @@ private: ...@@ -22,6 +20,7 @@ private:
static int skip_turn; static int skip_turn;
static int current_step; static int current_step;
static int skip_step; static int skip_step;
static void ReloadLocation(int player, int location, int flag, std::vector<unsigned char>& queryBuffer);
public: public:
static Replay cur_replay; static Replay cur_replay;
...@@ -37,9 +36,10 @@ public: ...@@ -37,9 +36,10 @@ public:
static void EndDuel(); static void EndDuel();
static void Restart(bool refresh); static void Restart(bool refresh);
static void Undo(); static void Undo();
static bool ReplayAnalyze(char* msg, unsigned int len); static bool ReplayAnalyze(unsigned char* msg, unsigned int len);
static void ReplayRefresh(int flag = 0xf81fff); static void ReplayRefresh(int flag = 0xf81fff);
static void ReplayRefreshLocation(int player, int location, int flag);
static void ReplayRefreshHand(int player, int flag = 0x781fff); static void ReplayRefreshHand(int player, int flag = 0x781fff);
static void ReplayRefreshGrave(int player, int flag = 0x181fff); static void ReplayRefreshGrave(int player, int flag = 0x181fff);
static void ReplayRefreshDeck(int player, int flag = 0x181fff); static void ReplayRefreshDeck(int player, int flag = 0x181fff);
...@@ -47,7 +47,7 @@ public: ...@@ -47,7 +47,7 @@ public:
static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); static void ReplayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void ReplayReload(); static void ReplayReload();
static int MessageHandler(intptr_t fduel, int type); static uint32 MessageHandler(intptr_t fduel, uint32 type);
}; };
} }
......
This diff is collapsed.
...@@ -24,7 +24,7 @@ public: ...@@ -24,7 +24,7 @@ public:
virtual void TPResult(DuelPlayer* dp, unsigned char tp); virtual void TPResult(DuelPlayer* dp, unsigned char tp);
virtual void Process(); virtual void Process();
virtual void Surrender(DuelPlayer* dp); virtual void Surrender(DuelPlayer* dp);
virtual int Analyze(char* msgbuffer, unsigned int len); virtual int Analyze(unsigned char* msgbuffer, unsigned int len);
virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len); virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len);
virtual void TimeConfirm(DuelPlayer* dp); virtual void TimeConfirm(DuelPlayer* dp);
virtual void EndDuel(); virtual void EndDuel();
...@@ -38,26 +38,28 @@ public: ...@@ -38,26 +38,28 @@ public:
void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1); void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static int MessageHandler(intptr_t fduel, int type); static uint32 MessageHandler(intptr_t fduel, uint32 type);
static void SingleTimer(evutil_socket_t fd, short events, void* arg); static void SingleTimer(evutil_socket_t fd, short events, void* arg);
private:
int WriteUpdateData(int& player, int location, int& flag, unsigned char*& qbuf, int& use_cache);
protected: protected:
DuelPlayer* players[2]; DuelPlayer* players[2]{ nullptr };
DuelPlayer* pplayer[2]; bool ready[2]{ false };
bool ready[2];
Deck pdeck[2]; Deck pdeck[2];
int deck_error[2]; int deck_error[2]{ 0 };
unsigned char hand_result[2]; unsigned char hand_result[2]{ 0 };
unsigned char last_response; unsigned char last_response{ 0 };
std::set<DuelPlayer*> observers; std::set<DuelPlayer*> observers;
Replay last_replay; Replay last_replay;
bool match_mode; bool match_mode{ false };
int match_kill; int match_kill{ 0 };
unsigned char duel_count; unsigned char duel_count{ 0 };
unsigned char tp_player; unsigned char tp_player{ 0 };
unsigned char match_result[3]; unsigned char match_result[3]{ 0 };
short time_limit[2]; short time_limit[2]{ 0 };
short time_elapsed; short time_elapsed{ 0 };
}; };
} }
......
This diff is collapsed.
#ifndef SINGLE_MODE_H #ifndef SINGLE_MODE_H
#define SINGLE_MODE_H #define SINGLE_MODE_H
#include <stdint.h>
#include <vector>
#include "replay.h" #include "replay.h"
namespace ygo { namespace ygo {
...@@ -10,15 +12,17 @@ private: ...@@ -10,15 +12,17 @@ private:
static intptr_t pduel; static intptr_t pduel;
static bool is_closing; static bool is_closing;
static bool is_continuing; static bool is_continuing;
static void ReloadLocation(int player, int location, int flag, std::vector<unsigned char>& queryBuffer);
public: public:
static bool StartPlay(); static bool StartPlay();
static void StopPlay(bool is_exiting = false); static void StopPlay(bool is_exiting = false);
static void SetResponse(unsigned char* resp, unsigned int len); static void SetResponse(unsigned char* resp, unsigned int len);
static int SinglePlayThread(); static int SinglePlayThread();
static bool SinglePlayAnalyze(char* msg, unsigned int len); static bool SinglePlayAnalyze(unsigned char* msg, unsigned int len);
static void SinglePlayRefresh(int flag = 0xf81fff); static void SinglePlayRefresh(int flag = 0xf81fff);
static void SingleRefreshLocation(int player, int location, int flag);
static void SinglePlayRefreshHand(int player, int flag = 0x781fff); static void SinglePlayRefreshHand(int player, int flag = 0x781fff);
static void SinglePlayRefreshGrave(int player, int flag = 0x181fff); static void SinglePlayRefreshGrave(int player, int flag = 0x181fff);
static void SinglePlayRefreshDeck(int player, int flag = 0x181fff); static void SinglePlayRefreshDeck(int player, int flag = 0x181fff);
...@@ -26,7 +30,7 @@ public: ...@@ -26,7 +30,7 @@ public:
static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); static void SinglePlayRefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static void SinglePlayReload(); static void SinglePlayReload();
static int MessageHandler(intptr_t fduel, int type); static uint32 MessageHandler(intptr_t fduel, uint32 type);
protected: protected:
static Replay last_replay; static Replay last_replay;
......
This diff is collapsed.
...@@ -24,7 +24,7 @@ public: ...@@ -24,7 +24,7 @@ public:
virtual void TPResult(DuelPlayer* dp, unsigned char tp); virtual void TPResult(DuelPlayer* dp, unsigned char tp);
virtual void Process(); virtual void Process();
virtual void Surrender(DuelPlayer* dp); virtual void Surrender(DuelPlayer* dp);
virtual int Analyze(char* msgbuffer, unsigned int len); virtual int Analyze(unsigned char* msgbuffer, unsigned int len);
virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len); virtual void GetResponse(DuelPlayer* dp, void* pdata, unsigned int len);
virtual void TimeConfirm(DuelPlayer* dp); virtual void TimeConfirm(DuelPlayer* dp);
virtual void EndDuel(); virtual void EndDuel();
...@@ -38,8 +38,11 @@ public: ...@@ -38,8 +38,11 @@ public:
void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1); void RefreshExtra(int player, int flag = 0xe81fff, int use_cache = 1);
void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff); void RefreshSingle(int player, int location, int sequence, int flag = 0xf81fff);
static int MessageHandler(intptr_t fduel, int type); static uint32 MessageHandler(intptr_t fduel, uint32 type);
static void TagTimer(evutil_socket_t fd, short events, void* arg); static void TagTimer(evutil_socket_t fd, short events, void* arg);
private:
int WriteUpdateData(int& player, int location, int& flag, unsigned char*& qbuf, int& use_cache);
protected: protected:
DuelPlayer* players[4]; DuelPlayer* players[4];
......
...@@ -779,6 +779,7 @@ ...@@ -779,6 +779,7 @@
!setname 0x51 零件 ガジェット !setname 0x51 零件 ガジェット
!setname 0x52 守护者 ガーディアン !setname 0x52 守护者 ガーディアン
!setname 0x1052 门之守护神|守护者 ゲート・ガーディアン !setname 0x1052 门之守护神|守护者 ゲート・ガーディアン
!setname 0x2052 法理守护者 ローガーディアン
!setname 0x53 星圣 セイクリッド !setname 0x53 星圣 セイクリッド
!setname 0x54 我我我 ガガガ !setname 0x54 我我我 ガガガ
!setname 0x55 光子 フォトン !setname 0x55 光子 フォトン
...@@ -905,6 +906,7 @@ ...@@ -905,6 +906,7 @@
!setname 0x10aa 隐藏的机壳 アポクリフォート !setname 0x10aa 隐藏的机壳 アポクリフォート
!setname 0xab 文具电子人|非「电子」 ブンボーグ !setname 0xab 文具电子人|非「电子」 ブンボーグ
!setname 0xac 哥布林 ゴブリン !setname 0xac 哥布林 ゴブリン
!setname 0x10ac 哥布林骑手 ゴブリンライダー
!setname 0xad 魔玩具 デストーイ !setname 0xad 魔玩具 デストーイ
!setname 0xae 契约书 契約書 !setname 0xae 契约书 契約書
!setname 0xaf DD !setname 0xaf DD
...@@ -1193,6 +1195,7 @@ ...@@ -1193,6 +1195,7 @@
!setname 0x19b 迪亚贝尔斯塔尔 ディアベルスター !setname 0x19b 迪亚贝尔斯塔尔 ディアベルスター
!setname 0x19c 蛇眼 スネークアイ !setname 0x19c 蛇眼 スネークアイ
!setname 0x19d 荷鲁斯 ホルス !setname 0x19d 荷鲁斯 ホルス
!setname 0x119d 荷鲁斯之黑炎龙 ホルスの黒炎竜
!setname 0x19e 罪宝 !setname 0x19e 罪宝
!setname 0x19f 圣菓使 聖菓使 !setname 0x19f 圣菓使 聖菓使
!setname 0x1a0 哈特 ハート !setname 0x1a0 哈特 ハート
...@@ -1200,3 +1203,6 @@ ...@@ -1200,3 +1203,6 @@
!setname 0x1a2 百夫长骑士 センチュリオン !setname 0x1a2 百夫长骑士 センチュリオン
!setname 0x1a3 异响鸣 ヴァルモニカ !setname 0x1a3 异响鸣 ヴァルモニカ
!setname 0x1a4 蒂斯蒂娜 Tistina !setname 0x1a4 蒂斯蒂娜 Tistina
!setname 0x1a5 于贝尔 ユベル
!setname 0x1a6 肃声 粛声
!setname 0x1a7 白斗气 ホワイト・オーラ
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment