Commit 636695b7 authored by argon.sun's avatar argon.sun

chat

parent 4f533571
...@@ -602,18 +602,18 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir ...@@ -602,18 +602,18 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir
else else
t->X = 1.9f + sequence * 4.0f / (count - 1); t->X = 1.9f + sequence * 4.0f / (count - 1);
if (pcard->is_hovered) { if (pcard->is_hovered) {
t->Y = 3.82f; t->Y = 3.84f;
t->Z = 0.64f + 0.001f * sequence; t->Z = 0.656f + 0.001f * sequence;
} else { } else {
t->Y = 4.0f; t->Y = 4.0f;
t->Z = 0.5f + 0.001f * sequence; t->Z = 0.5f + 0.001f * sequence;
} }
if(pcard->code) { if(pcard->code) {
r->X = -0.661f; r->X = -0.798056f;
r->Y = 0.0f; r->Y = 0.0f;
r->Z = 0.0f; r->Z = 0.0f;
} else { } else {
r->X = 0.661f; r->X = 0.798056f;
r->Y = 3.1415926f; r->Y = 3.1415926f;
r->Z = 0; r->Z = 0;
} }
...@@ -623,18 +623,18 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir ...@@ -623,18 +623,18 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir
else else
t->X = 5.9f - sequence * 4.0f / (count - 1); t->X = 5.9f - sequence * 4.0f / (count - 1);
if (pcard->is_hovered) { if (pcard->is_hovered) {
t->Y = -3.58f; t->Y = -3.56f;
t->Z = 0.64f - 0.001f * sequence; t->Z = 0.656f - 0.001f * sequence;
} else { } else {
t->Y = -3.4f; t->Y = -3.4f;
t->Z = 0.5f - 0.001f * sequence; t->Z = 0.5f - 0.001f * sequence;
} }
if (pcard->code == 0) { if (pcard->code == 0) {
r->X = 0.661f; r->X = 0.798056f;
r->Y = 3.1415926f; r->Y = 3.1415926f;
r->Z = 0; r->Z = 0;
} else { } else {
r->X = -0.661f; r->X = -0.798056f;
r->Y = 0; r->Y = 0;
r->Z = 0; r->Z = 0;
} }
......
...@@ -315,72 +315,79 @@ void Game::DrawMisc() { ...@@ -315,72 +315,79 @@ void Game::DrawMisc() {
for(int i = 0; i < 5; ++i) { for(int i = 0; i < 5; ++i) {
ClientCard* pcard = dField.mzone[0][i]; ClientCard* pcard = dField.mzone[0][i];
if(pcard) { if(pcard) {
int m = 491 + i * 86; int m = 483 + i * 90;
adFont->draw(L"/", recti(m - 4, 403, m + 4, 423), 0xff000000, true, false, 0); adFont->draw(L"/", recti(m - 4, 396, m + 4, 416), 0xff000000, true, false, 0);
adFont->draw(L"/", recti(m - 3, 404, m + 5, 424), 0xffffffff, true, false, 0); adFont->draw(L"/", recti(m - 3, 397, m + 5, 417), 0xffffffff, true, false, 0);
int w = adFont->getDimension(pcard->atkstring).Width; int w = adFont->getDimension(pcard->atkstring).Width;
adFont->draw(pcard->atkstring, recti(m - 5 - w, 403, m - 5, 423), 0xff000000, false, false, 0); adFont->draw(pcard->atkstring, recti(m - 5 - w, 396, m - 5, 416), 0xff000000, false, false, 0);
adFont->draw(pcard->atkstring, recti(m - 4 - w, 404, m - 4, 424), adFont->draw(pcard->atkstring, recti(m - 4 - w, 397, m - 4, 417),
pcard->attack > pcard->base_attack ? 0xffffff00 : pcard->attack < pcard->base_attack ? 0xffff2090 : 0xffffffff , false, false, 0); pcard->attack > pcard->base_attack ? 0xffffff00 : pcard->attack < pcard->base_attack ? 0xffff2090 : 0xffffffff , false, false, 0);
w = adFont->getDimension(pcard->defstring).Width; w = adFont->getDimension(pcard->defstring).Width;
adFont->draw(pcard->defstring, recti(m + 4, 403, m + 4 + w, 423), 0xff000000, false, false, 0); adFont->draw(pcard->defstring, recti(m + 4, 396, m + 4 + w, 416), 0xff000000, false, false, 0);
adFont->draw(pcard->defstring, recti(m + 5, 404, m + 5 + w, 424), adFont->draw(pcard->defstring, recti(m + 5, 397, m + 5 + w, 417),
pcard->defence > pcard->base_defence ? 0xffffff00 : pcard->defence < pcard->base_defence ? 0xffff2090 : 0xffffffff , false, false, 0); pcard->defence > pcard->base_defence ? 0xffffff00 : pcard->defence < pcard->base_defence ? 0xffff2090 : 0xffffffff , false, false, 0);
adFont->draw(pcard->lvstring, recti(468 + i * 83, 347, 500 + i * 83, 367), 0xff000000, false, false, 0); adFont->draw(pcard->lvstring, recti(463 + i * 85, 346, 495 + i * 85, 366), 0xff000000, false, false, 0);
adFont->draw(pcard->lvstring, recti(469 + i * 83, 348, 501 + i * 83, 368), adFont->draw(pcard->lvstring, recti(464 + i * 85, 347, 496 + i * 85, 367),
(pcard->type & TYPE_XYZ) ? 0xffff80ff : (pcard->type & TYPE_TUNER) ? 0xffffff00 : 0xffffffff, false, false, 0); (pcard->type & TYPE_XYZ) ? 0xffff80ff : (pcard->type & TYPE_TUNER) ? 0xffffff00 : 0xffffffff, false, false, 0);
} }
} }
for(int i = 0; i < 5; ++i) { for(int i = 0; i < 5; ++i) {
ClientCard* pcard = dField.mzone[1][i]; ClientCard* pcard = dField.mzone[1][i];
if(pcard && (pcard->position & POS_FACEUP)) { if(pcard && (pcard->position & POS_FACEUP)) {
int m = 808 - i * 72; int m = 810 - i * 73;
adFont->draw(L"/", recti(m - 4, 235, m + 4, 255), 0xff000000, true, false, 0); adFont->draw(L"/", recti(m - 4, 245, m + 4, 265), 0xff000000, true, false, 0);
adFont->draw(L"/", recti(m - 3, 236, m + 5, 256), 0xffffffff, true, false, 0); adFont->draw(L"/", recti(m - 3, 246, m + 5, 266), 0xffffffff, true, false, 0);
int w = adFont->getDimension(pcard->atkstring).Width; int w = adFont->getDimension(pcard->atkstring).Width;
adFont->draw(pcard->atkstring, recti(m - 5 - w, 235, m - 5, 255), 0xff000000, false, false, 0); adFont->draw(pcard->atkstring, recti(m - 5 - w, 245, m - 5, 265), 0xff000000, false, false, 0);
adFont->draw(pcard->atkstring, recti(m - 4 - w, 236, m - 4, 256), adFont->draw(pcard->atkstring, recti(m - 4 - w, 246, m - 4, 266),
pcard->attack > pcard->base_attack ? 0xffffff00 : pcard->attack < pcard->base_attack ? 0xffff2090 : 0xffffffff , false, false, 0); pcard->attack > pcard->base_attack ? 0xffffff00 : pcard->attack < pcard->base_attack ? 0xffff2090 : 0xffffffff , false, false, 0);
w = adFont->getDimension(pcard->defstring).Width; w = adFont->getDimension(pcard->defstring).Width;
adFont->draw(pcard->defstring, recti(m + 4, 235, m + 4 + w, 255), 0xff000000, false, false, 0); adFont->draw(pcard->defstring, recti(m + 4, 245, m + 4 + w, 265), 0xff000000, false, false, 0);
adFont->draw(pcard->defstring, recti(m + 5, 236, m + 5 + w, 256), adFont->draw(pcard->defstring, recti(m + 5, 246, m + 5 + w, 266),
pcard->defence > pcard->base_defence ? 0xffffff00 : pcard->defence < pcard->base_defence ? 0xffff2090 : 0xffffffff , false, false, 0); pcard->defence > pcard->base_defence ? 0xffffff00 : pcard->defence < pcard->base_defence ? 0xffff2090 : 0xffffffff , false, false, 0);
adFont->draw(pcard->lvstring, recti(789 - i * 76, 280, 820 - i * 76, 300), 0xff000000, false, false, 0); adFont->draw(pcard->lvstring, recti(789 - i * 76, 282, 820 - i * 76, 302), 0xff000000, false, false, 0);
adFont->draw(pcard->lvstring, recti(789 - i * 76, 281, 820 - i * 76, 301), adFont->draw(pcard->lvstring, recti(789 - i * 76, 283, 820 - i * 76, 303),
(pcard->type & TYPE_XYZ) ? 0xffff80ff : (pcard->type & TYPE_TUNER) ? 0xffffff00 : 0xffffffff, false, false, 0); (pcard->type & TYPE_XYZ) ? 0xffff80ff : (pcard->type & TYPE_TUNER) ? 0xffffff00 : 0xffffffff, false, false, 0);
} }
} }
if(dField.extra[0].size()) { if(dField.extra[0].size()) {
numFont->draw(dataManager.GetNumString(dField.extra[0].size()), recti(337, 540, 397, 560), 0xff000000, true, false, 0); numFont->draw(dataManager.GetNumString(dField.extra[0].size()), recti(305, 532, 381, 552), 0xff000000, true, false, 0);
numFont->draw(dataManager.GetNumString(dField.extra[0].size()), recti(337, 541, 399, 561), 0xffffff00, true, false, 0); numFont->draw(dataManager.GetNumString(dField.extra[0].size()), recti(305, 533, 383, 553), 0xffffff00, true, false, 0);
} }
if(dField.deck[0].size()) { if(dField.deck[0].size()) {
numFont->draw(dataManager.GetNumString(dField.deck[0].size()), recti(934, 540, 994, 560), 0xff000000, true, false, 0); numFont->draw(dataManager.GetNumString(dField.deck[0].size()), recti(942, 532, 1021, 552), 0xff000000, true, false, 0);
numFont->draw(dataManager.GetNumString(dField.deck[0].size()), recti(934, 541, 996, 561), 0xffffff00, true, false, 0); numFont->draw(dataManager.GetNumString(dField.deck[0].size()), recti(943, 533, 1023, 553), 0xffffff00, true, false, 0);
} }
if(dField.grave[0].size()) { if(dField.grave[0].size()) {
numFont->draw(dataManager.GetNumString(dField.grave[0].size()), recti(910, 442, 970, 462), 0xff000000, true, false, 0); numFont->draw(dataManager.GetNumString(dField.grave[0].size()), recti(917, 436, 984, 456), 0xff000000, true, false, 0);
numFont->draw(dataManager.GetNumString(dField.grave[0].size()), recti(910, 443, 972, 463), 0xffffff00, true, false, 0); numFont->draw(dataManager.GetNumString(dField.grave[0].size()), recti(917, 437, 986, 457), 0xffffff00, true, false, 0);
} }
if(dField.remove[0].size()) { if(dField.remove[0].size()) {
numFont->draw(dataManager.GetNumString(dField.remove[0].size()), recti(888, 359, 948, 359), 0xff000000, true, false, 0); numFont->draw(dataManager.GetNumString(dField.remove[0].size()), recti(895, 360, 957, 380), 0xff000000, true, false, 0);
numFont->draw(dataManager.GetNumString(dField.remove[0].size()), recti(888, 360, 950, 360), 0xffffff00, true, false, 0); numFont->draw(dataManager.GetNumString(dField.remove[0].size()), recti(895, 361, 959, 381), 0xffffff00, true, false, 0);
} }
if(dField.extra[1].size()) { if(dField.extra[1].size()) {
numFont->draw(dataManager.GetNumString(dField.extra[1].size()), recti(848, 194, 908, 214), 0xff000000, true, false, 0); numFont->draw(dataManager.GetNumString(dField.extra[1].size()), recti(848, 212, 908, 232), 0xff000000, true, false, 0);
numFont->draw(dataManager.GetNumString(dField.extra[1].size()), recti(848, 195, 910, 215), 0xffffff00, true, false, 0); numFont->draw(dataManager.GetNumString(dField.extra[1].size()), recti(848, 213, 910, 233), 0xffffff00, true, false, 0);
} }
if(dField.deck[1].size()) { if(dField.deck[1].size()) {
numFont->draw(dataManager.GetNumString(dField.deck[1].size()), recti(421, 194, 481, 214), 0xff000000, true, false, 0); numFont->draw(dataManager.GetNumString(dField.deck[1].size()), recti(421, 212, 481, 232), 0xff000000, true, false, 0);
numFont->draw(dataManager.GetNumString(dField.deck[1].size()), recti(421, 195, 483, 215), 0xffffff00, true, false, 0); numFont->draw(dataManager.GetNumString(dField.deck[1].size()), recti(421, 213, 483, 233), 0xffffff00, true, false, 0);
} }
if(dField.grave[1].size()) { if(dField.grave[1].size()) {
numFont->draw(dataManager.GetNumString(dField.grave[1].size()), recti(408, 250, 469, 270), 0xff000000, true, false, 0); numFont->draw(dataManager.GetNumString(dField.grave[1].size()), recti(408, 261, 462, 281), 0xff000000, true, false, 0);
numFont->draw(dataManager.GetNumString(dField.grave[1].size()), recti(408, 251, 471, 271), 0xffffff00, true, false, 0); numFont->draw(dataManager.GetNumString(dField.grave[1].size()), recti(408, 262, 464, 282), 0xffffff00, true, false, 0);
} }
if(dField.remove[1].size()) { if(dField.remove[1].size()) {
numFont->draw(dataManager.GetNumString(dField.remove[1].size()), recti(392, 315, 453, 335), 0xff000000, true, false, 0); numFont->draw(dataManager.GetNumString(dField.remove[1].size()), recti(386, 320, 443, 340), 0xff000000, true, false, 0);
numFont->draw(dataManager.GetNumString(dField.remove[1].size()), recti(392, 316, 455, 336), 0xffffff00, true, false, 0); numFont->draw(dataManager.GetNumString(dField.remove[1].size()), recti(386, 321, 445, 341), 0xffffff00, true, false, 0);
}
for(int i = 0; i < 5; ++i) {
if(chatTiming[i]) {
chatTiming[i]--;
textFont->draw(chatMsg[i].c_str(), rect<s32>(305, 595 - 20 * i, 1020, 615 - 20 * i), 0xff000000, false, false);
textFont->draw(chatMsg[i].c_str(), rect<s32>(306, 596 - 20 * i, 1021, 616 - 20 * i), 0xffffffff, false, false);
}
} }
} }
void Game::DrawGUI() { void Game::DrawGUI() {
......
...@@ -465,6 +465,26 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -465,6 +465,26 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->dInfo.time_left[lplayer] = pkt->left_time; mainGame->dInfo.time_left[lplayer] = pkt->left_time;
break; break;
} }
case STOC_CHAT: {
STOC_Chat* pkt = (STOC_Chat*)pdata;
wchar_t msg[256];
if(pkt->player < 2) {
if(mainGame->chkIgnore1->isChecked())
break;
BufferIO::CopyWStr(pkt->msg, msg, 256);
mainGame->gMutex.Lock();
mainGame->AddChatMsg(msg, mainGame->LocalPlayer(pkt->player));
mainGame->gMutex.Unlock();
} else {
if(mainGame->chkIgnore2->isChecked())
break;
BufferIO::CopyWStr(pkt->msg, msg, 256);
mainGame->gMutex.Lock();
mainGame->AddChatMsg(msg, 2);
mainGame->gMutex.Unlock();
}
break;
}
case STOC_HS_PLAYER_ENTER: { case STOC_HS_PLAYER_ENTER: {
STOC_HS_PlayerEnter* pkt = (STOC_HS_PlayerEnter*)pdata; STOC_HS_PlayerEnter* pkt = (STOC_HS_PlayerEnter*)pdata;
if(pkt->pos > 1) if(pkt->pos > 1)
......
...@@ -762,6 +762,21 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -762,6 +762,21 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
} }
break; break;
} }
case EDITBOX_CHAT: {
if(mainGame->dInfo.isReplay)
break;
const wchar_t* input = mainGame->ebChatInput->getText();
if(input[0]) {
unsigned short msgbuf[256];
if(!mainGame->dInfo.isObserver)
mainGame->AddChatMsg((wchar_t*)input, 0);
else mainGame->AddChatMsg((wchar_t*)input, 2);
int len = BufferIO::CopyWStr(input, msgbuf, 256);
DuelClient::SendBufferToServer(CTOS_CHAT, msgbuf, len * sizeof(short));
mainGame->ebChatInput->setText(L"");
}
break;
}
} }
break; break;
} }
...@@ -1357,21 +1372,21 @@ bool ClientField::OnEvent(const irr::SEvent& event) { ...@@ -1357,21 +1372,21 @@ bool ClientField::OnEvent(const irr::SEvent& event) {
return false; return false;
} }
void ClientField::GetHoverField(int x, int y) { void ClientField::GetHoverField(int x, int y) {
irr::core::recti sfRect(433, 528, 883, 618); irr::core::recti sfRect(416, 504, 900, 600);
irr::core::recti ofRect(513, 117, 807, 175); irr::core::recti ofRect(516, 135, 805, 191);
irr::core::position2di pos(x, y); irr::core::position2di pos(x, y);
if(sfRect.isPointInside(pos)) { if(sfRect.isPointInside(pos)) {
int hc = hand[0].size(); int hc = hand[0].size();
if(hc == 0) if(hc == 0)
hovered_location = 0; hovered_location = 0;
else if(hc < 7) { else if(hc < 7) {
int left = 433 + 77 * (6 - hc) / 2; int left = 416 + 82 * (6 - hc) / 2;
if(x < left) if(x < left)
hovered_location = 0; hovered_location = 0;
else { else {
int seq = (x - left) / 77; int seq = (x - left) / 82;
if(seq >= hc) seq = hc - 1; if(seq >= hc) seq = hc - 1;
if(x - left - 77 * seq < 68) { if(x - left - 82 * seq < 71) {
hovered_controler = 0; hovered_controler = 0;
hovered_location = LOCATION_HAND; hovered_location = LOCATION_HAND;
hovered_sequence = seq; hovered_sequence = seq;
...@@ -1380,23 +1395,23 @@ void ClientField::GetHoverField(int x, int y) { ...@@ -1380,23 +1395,23 @@ void ClientField::GetHoverField(int x, int y) {
} else { } else {
hovered_controler = 0; hovered_controler = 0;
hovered_location = LOCATION_HAND; hovered_location = LOCATION_HAND;
if(x >= 817) if(x >= 829)
hovered_sequence = hc - 1; hovered_sequence = hc - 1;
else else
hovered_sequence = (x - 433) * (hc - 1) / 384; hovered_sequence = (x - 416) * (hc - 1) / 413;
} }
} else if(ofRect.isPointInside(pos)) { } else if(ofRect.isPointInside(pos)) {
int hc = hand[1].size(); int hc = hand[1].size();
if(hc == 0) if(hc == 0)
hovered_location = 0; hovered_location = 0;
else if(hc < 7) { else if(hc < 7) {
int left = 513 + 50 * (6 - hc) / 2; int left = 516 + 49 * (6 - hc) / 2;
if(x < left) if(x < left)
hovered_location = 0; hovered_location = 0;
else { else {
int seq = (x - left) / 50; int seq = (x - left) / 49;
if(seq >= hc) seq = hc - 1; if(seq >= hc) seq = hc - 1;
if(x - left - 50 * seq < 45) { if(x - left - 49 * seq < 42) {
hovered_controler = 1; hovered_controler = 1;
hovered_location = LOCATION_HAND; hovered_location = LOCATION_HAND;
hovered_sequence = hc - 1 - seq; hovered_sequence = hc - 1 - seq;
...@@ -1405,18 +1420,18 @@ void ClientField::GetHoverField(int x, int y) { ...@@ -1405,18 +1420,18 @@ void ClientField::GetHoverField(int x, int y) {
} else { } else {
hovered_controler = 1; hovered_controler = 1;
hovered_location = LOCATION_HAND; hovered_location = LOCATION_HAND;
if(x >= 763) if(x >= 756)
hovered_sequence = 0; hovered_sequence = 0;
else else
hovered_sequence = hc - 1 - (x - 513) * (hc - 1) / 250; hovered_sequence = hc - 1 - (x - 516) * (hc - 1) / 247;
} }
} else { } else {
double screenx = x / 1024.0 * 1.25 - 0.81; double screenx = x / 1024.0 * 1.25 - 0.81;
double screeny = y / 640.0 * 0.84 - 0.42; double screeny = y / 640.0 * 0.84 - 0.42;
double angle = 0.66104316885 - atan(screeny); //0.66104316885 = arctan(7.0/9.0) double angle = 0.798056 - atan(screeny); //0.798056 = arctan(8.0/7.8)
double vlen = sqrt(1.0 + screeny * screeny); double vlen = sqrt(1.0 + screeny * screeny);
double boardx = 3.95 + 9.0 * screenx / vlen / cos(angle); double boardx = 3.95 + 7.8 * screenx / vlen / cos(angle);
double boardy = 7.0 - 9.0 * tan(angle); double boardy = 8.0 - 7.8 * tan(angle);
hovered_location = 0; hovered_location = 0;
if(boardx >= 0.2 && boardx <= 1.0) { if(boardx >= 0.2 && boardx <= 1.0) {
if(boardy >= 2.4 && boardy <= 3.6) { if(boardy >= 2.4 && boardy <= 3.6) {
......
...@@ -464,7 +464,7 @@ void Game::MainLoop() { ...@@ -464,7 +464,7 @@ void Game::MainLoop() {
irr::core::matrix4 mProjection; irr::core::matrix4 mProjection;
BuildProjectionMatrix(mProjection, -0.81f, 0.44f, -0.42f, 0.42f, 1.0f, 100.0f); BuildProjectionMatrix(mProjection, -0.81f, 0.44f, -0.42f, 0.42f, 1.0f, 100.0f);
camera->setProjectionMatrix(mProjection); camera->setProjectionMatrix(mProjection);
mProjection.buildCameraLookAtMatrixLH(vector3df(3.95f, 7.0f, 9.0f), vector3df(3.95f, 0, 0), vector3df(0, 0, 1)); mProjection.buildCameraLookAtMatrixLH(vector3df(3.95f, 8.0f, 7.8f), vector3df(3.95f, 0, 0), vector3df(0, 0, 1));
camera->setViewMatrixAffector(mProjection); camera->setViewMatrixAffector(mProjection);
irr::scene::ILightSceneNode* light = smgr->addLightSceneNode(0, vector3df(0, 0, 100)); irr::scene::ILightSceneNode* light = smgr->addLightSceneNode(0, vector3df(0, 0, 100));
light->getLightData().AmbientColor = SColorf(1.0f, 1.0f, 1.0f); light->getLightData().AmbientColor = SColorf(1.0f, 1.0f, 1.0f);
...@@ -653,7 +653,7 @@ void Game::LoadConfig() { ...@@ -653,7 +653,7 @@ void Game::LoadConfig() {
gameConf.textfont[0] = 0; gameConf.textfont[0] = 0;
gameConf.lastip[0] = 0; gameConf.lastip[0] = 0;
gameConf.lastport[0] = 0; gameConf.lastport[0] = 0;
gameConf.roompass[0] = 0; gameConf.roompass[0] = 0;
fseek(fp, 0, SEEK_END); fseek(fp, 0, SEEK_END);
size_t fsize = ftell(fp); size_t fsize = ftell(fp);
fseek(fp, 0, SEEK_SET); fseek(fp, 0, SEEK_SET);
...@@ -688,7 +688,7 @@ void Game::LoadConfig() { ...@@ -688,7 +688,7 @@ void Game::LoadConfig() {
BufferIO::CopyWStr(wstr, gameConf.lastport, 20); BufferIO::CopyWStr(wstr, gameConf.lastport, 20);
} else if(!strcmp(strbuf, "roompass")) { } else if(!strcmp(strbuf, "roompass")) {
BufferIO::DecodeUTF8(valbuf, wstr); BufferIO::DecodeUTF8(valbuf, wstr);
BufferIO::CopyWStr(wstr, gameConf.roompass, 20); BufferIO::CopyWStr(wstr, gameConf.roompass, 20);
} }
} }
fclose(fp); fclose(fp);
...@@ -720,7 +720,7 @@ void Game::ShowCardInfo(int code) { ...@@ -720,7 +720,7 @@ void Game::ShowCardInfo(int code) {
CardData cd; CardData cd;
wchar_t formatBuffer[256]; wchar_t formatBuffer[256];
dataManager.GetData(code, &cd); dataManager.GetData(code, &cd);
imgCard->setImage(imageManager.GetTexture(code)); imgCard->setImage(imageManager.GetTexture(code));
imgCard->setScaleImage(true); //I don't know weather check size or not will be faster; if Irrlicht don't check size internal and cause slow, check size like Game::DrawThumb() imgCard->setScaleImage(true); //I don't know weather check size or not will be faster; if Irrlicht don't check size internal and cause slow, check size like Game::DrawThumb()
if(cd.alias != 0 && (cd.alias - code < 10 || code - cd.alias < 10)) if(cd.alias != 0 && (cd.alias - code < 10 || code - cd.alias < 10))
myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(cd.alias), cd.alias); myswprintf(formatBuffer, L"%ls[%08d]", dataManager.GetName(cd.alias), cd.alias);
...@@ -752,6 +752,21 @@ void Game::ShowCardInfo(int code) { ...@@ -752,6 +752,21 @@ void Game::ShowCardInfo(int code) {
} }
SetStaticText(stText, 270, textFont, (wchar_t*)dataManager.GetText(code)); SetStaticText(stText, 270, textFont, (wchar_t*)dataManager.GetText(code));
} }
void Game::AddChatMsg(wchar_t* msg, int player) {
for(int i = 4; i > 0; --i) {
chatMsg[i] = chatMsg[i - 1];
chatTiming[i] = chatTiming[i - 1];
}
chatMsg[0].clear();
chatTiming[0] = 600;
if(player == 0)
chatMsg[0].append(dInfo.hostname);
else if(player == 1)
chatMsg[0].append(dInfo.clientname);
else chatMsg[0].append(L"[***]");
chatMsg[0].append(L": ");
chatMsg[0].append(msg);
}
void Game::ClearTextures() { void Game::ClearTextures() {
matManager.mCard.setTexture(0, 0); matManager.mCard.setTexture(0, 0);
mainGame->imgCard->setImage(0); mainGame->imgCard->setImage(0);
......
...@@ -22,7 +22,7 @@ struct Config { ...@@ -22,7 +22,7 @@ struct Config {
wchar_t lastdeck[64]; wchar_t lastdeck[64];
wchar_t textfont[256]; wchar_t textfont[256];
wchar_t numfont[256]; wchar_t numfont[256];
wchar_t roompass[20]; wchar_t roompass[20];
}; };
struct DuelInfo { struct DuelInfo {
...@@ -81,6 +81,7 @@ public: ...@@ -81,6 +81,7 @@ public:
void LoadConfig(); void LoadConfig();
void SaveConfig(); void SaveConfig();
void ShowCardInfo(int code); void ShowCardInfo(int code);
void AddChatMsg(wchar_t* msg, int player);
void ClearTextures(); void ClearTextures();
void CloseDuelWindow(); void CloseDuelWindow();
...@@ -97,6 +98,8 @@ public: ...@@ -97,6 +98,8 @@ public:
std::list<FadingUnit> fadingList; std::list<FadingUnit> fadingList;
std::vector<int> logParam; std::vector<int> logParam;
std::wstring chatMsg[5];
int chatTiming[5];
unsigned short linePattern; unsigned short linePattern;
int waitFrame; int waitFrame;
int signalFrame; int signalFrame;
......
...@@ -186,6 +186,12 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) { ...@@ -186,6 +186,12 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) {
duel_mode->TimeConfirm(dp); duel_mode->TimeConfirm(dp);
break; break;
} }
case CTOS_CHAT: {
if(!dp->game)
return;
duel_mode->Chat(dp, data, len);
break;
}
case CTOS_UPDATE_DECK: { case CTOS_UPDATE_DECK: {
if(!dp->game) if(!dp->game)
return; return;
......
...@@ -80,6 +80,10 @@ struct STOC_TimeLimit { ...@@ -80,6 +80,10 @@ struct STOC_TimeLimit {
unsigned char player; unsigned char player;
unsigned short left_time; unsigned short left_time;
}; };
struct STOC_Chat {
unsigned char player;
unsigned short msg[256];
};
struct STOC_HS_PlayerEnter { struct STOC_HS_PlayerEnter {
unsigned short name[20]; unsigned short name[20];
unsigned char pos; unsigned char pos;
...@@ -112,6 +116,7 @@ class DuelMode { ...@@ -112,6 +116,7 @@ class DuelMode {
public: public:
DuelMode(): host_player(0), pduel(0) {} DuelMode(): host_player(0), pduel(0) {}
virtual ~DuelMode() {} virtual ~DuelMode() {}
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) {}
virtual void LeaveGame(DuelPlayer* dp) {} virtual void LeaveGame(DuelPlayer* dp) {}
virtual void ToDuelist(DuelPlayer* dp) {} virtual void ToDuelist(DuelPlayer* dp) {}
...@@ -163,6 +168,7 @@ public: ...@@ -163,6 +168,7 @@ public:
#define CTOS_LEAVE_GAME 0x13 #define CTOS_LEAVE_GAME 0x13
#define CTOS_SURRENDER 0x14 #define CTOS_SURRENDER 0x14
#define CTOS_TIME_CONFIRM 0x15 #define CTOS_TIME_CONFIRM 0x15
#define CTOS_CHAT 0x16
#define CTOS_HS_TODUELIST 0x20 #define CTOS_HS_TODUELIST 0x20
#define CTOS_HS_TOOBSERVER 0x21 #define CTOS_HS_TOOBSERVER 0x21
#define CTOS_HS_READY 0x22 #define CTOS_HS_READY 0x22
...@@ -186,6 +192,7 @@ public: ...@@ -186,6 +192,7 @@ public:
#define STOC_DUEL_END 0x16 #define STOC_DUEL_END 0x16
#define STOC_REPLAY 0x17 #define STOC_REPLAY 0x17
#define STOC_TIME_LIMIT 0x18 #define STOC_TIME_LIMIT 0x18
#define STOC_CHAT 0x19
#define STOC_HS_PLAYER_ENTER 0x20 #define STOC_HS_PLAYER_ENTER 0x20
#define STOC_HS_PLAYER_CHANGE 0x21 #define STOC_HS_PLAYER_CHANGE 0x21
#define STOC_HS_WATCH_CHANGE 0x22 #define STOC_HS_WATCH_CHANGE 0x22
......
...@@ -18,6 +18,24 @@ SingleDuel::SingleDuel(bool is_match) { ...@@ -18,6 +18,24 @@ SingleDuel::SingleDuel(bool is_match) {
memset(match_result, 0, 3); memset(match_result, 0, 3);
} }
SingleDuel::~SingleDuel() { SingleDuel::~SingleDuel() {
}
void SingleDuel::Chat(DuelPlayer* dp, void* pdata, int len) {
STOC_Chat scc;
scc.player = dp->type;
unsigned short* msg = (unsigned short*)pdata;
int msglen = BufferIO::CopyWStr(msg, scc.msg, 256);
if(dp->type < 2) {
NetServer::SendBufferToPlayer(players[0], STOC_CHAT, &scc, 1 + msglen * 2);
NetServer::SendBufferToPlayer(players[1], STOC_CHAT, &scc, 1 + msglen * 2);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
if((*pit) != dp)
NetServer::ReSendToPlayer(*pit);
} else {
NetServer::SendBufferToPlayer(players[1 - dp->type], STOC_CHAT, &scc, 1 + msglen * 2);
for(auto pit = observers.begin(); pit != observers.end(); ++pit)
NetServer::ReSendToPlayer(*pit);
}
} }
void SingleDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) { void SingleDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
if(!is_creater) { if(!is_creater) {
......
...@@ -11,6 +11,7 @@ class SingleDuel: public DuelMode { ...@@ -11,6 +11,7 @@ class SingleDuel: public DuelMode {
public: public:
SingleDuel(bool is_match); SingleDuel(bool is_match);
virtual ~SingleDuel(); virtual ~SingleDuel();
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);
virtual void LeaveGame(DuelPlayer* dp); virtual void LeaveGame(DuelPlayer* dp);
virtual void ToDuelist(DuelPlayer* dp); virtual void ToDuelist(DuelPlayer* dp);
......
...@@ -921,7 +921,8 @@ int32 scriptlib::card_enable_revive_limit(lua_State *L) { ...@@ -921,7 +921,8 @@ int32 scriptlib::card_enable_revive_limit(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_CARD, 1); check_param(L, PARAM_TYPE_CARD, 1);
card* pcard = *(card**) lua_touserdata(L, 1); card* pcard = *(card**) lua_touserdata(L, 1);
pcard->set_status(STATUS_REVIVE_LIMIT, TRUE); if(!pcard->is_status(STATUS_COPYING_EFFECT))
pcard->set_status(STATUS_REVIVE_LIMIT, TRUE);
return 0; return 0;
} }
int32 scriptlib::card_complete_procedure(lua_State *L) { int32 scriptlib::card_complete_procedure(lua_State *L) {
......
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