Commit bcdf102e authored by argon.sun's avatar argon.sun

fix

parent d5dbbba1
......@@ -8,9 +8,10 @@ namespace irr {
namespace gui {
void Draw2DImageRotation(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> position, core::position2d<s32> rotationPoint, f32 rotation = 0.0f,
core::vector2df scale = core::vector2df(1.0, 1.0), bool useAlphaChannel = true, video::SColor color = 0xffffffff);
core::position2d<s32> position, core::position2d<s32> rotationPoint, f32 rotation = 0.0f,
core::vector2df scale = core::vector2df(1.0, 1.0), bool useAlphaChannel = true, video::SColor color = 0xffffffff);
void Draw2DImageQuad(video::IVideoDriver* driver, video::ITexture* image, core::rect<s32> sourceRect,
core::position2d<s32> corner[4], bool useAlphaChannel = true, video::SColor color = 0xffffffff);
class CGUIImageButton : public CGUIButton {
public:
CGUIImageButton(IGUIEnvironment* environment, IGUIElement* parent, s32 id, core::rect<s32> rectangle);
......@@ -22,7 +23,7 @@ public:
private:
bool isDrawImage;
f32 imageRotation;
f32 imageRotation;
core::vector2df imageScale;
};
......
......@@ -455,8 +455,8 @@ void Game::DrawSpec() {
if(showcard) {
switch(showcard) {
case 1: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 200));
driver->draw2DImage(imageManager.tMask, recti(574, 200, 574 + (showcarddif > 177 ? 177 : showcarddif), 454),
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 150));
driver->draw2DImage(imageManager.tMask, recti(574, 150, 574 + (showcarddif > 177 ? 177 : showcarddif), 404),
recti(254 - showcarddif, 0, 254 - (showcarddif > 177 ? showcarddif - 177 : 0), 254), 0, 0, true);
showcarddif += 15;
if(showcarddif >= 254) {
......@@ -466,8 +466,8 @@ void Game::DrawSpec() {
break;
}
case 2: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 200));
driver->draw2DImage(imageManager.tMask, recti(574 + showcarddif, 200, 761, 454), recti(0, 0, 177 - showcarddif, 254), 0, 0, true);
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 150));
driver->draw2DImage(imageManager.tMask, recti(574 + showcarddif, 150, 761, 404), recti(0, 0, 177 - showcarddif, 254), 0, 0, true);
showcarddif += 15;
if(showcarddif >= 177) {
showcard = 0;
......@@ -475,8 +475,8 @@ void Game::DrawSpec() {
break;
}
case 3: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 200));
driver->draw2DImage(imageManager.tNegated, recti(536 + showcarddif, 191 + showcarddif, 793 - showcarddif, 447 - showcarddif), recti(0, 0, 128, 128), 0, 0, true);
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 150));
driver->draw2DImage(imageManager.tNegated, recti(536 + showcarddif, 141 + showcarddif, 793 - showcarddif, 397 - showcarddif), recti(0, 0, 128, 128), 0, 0, true);
if(showcarddif < 64)
showcarddif += 4;
break;
......@@ -486,7 +486,7 @@ void Game::DrawSpec() {
matManager.c2d[1] = (showcarddif << 24) | 0xffffff;
matManager.c2d[2] = (showcarddif << 24) | 0xffffff;
matManager.c2d[3] = (showcarddif << 24) | 0xffffff;
driver->draw2DImage(imageManager.GetTexture(showcardcode), recti(574, 200, 751, 454),
driver->draw2DImage(imageManager.GetTexture(showcardcode), recti(574, 154, 751, 404),
recti(0, 0, 177, 254), 0, matManager.c2d, true);
if(showcarddif < 255)
showcarddif += 17;
......@@ -497,20 +497,38 @@ void Game::DrawSpec() {
matManager.c2d[1] = (showcarddif << 25) | 0xffffff;
matManager.c2d[2] = (showcarddif << 25) | 0xffffff;
matManager.c2d[3] = (showcarddif << 25) | 0xffffff;
driver->draw2DImage(imageManager.GetTexture(showcardcode), recti(662 - showcarddif * 0.69685f, 327 - showcarddif, 662 + showcarddif * 0.69685f, 327 + showcarddif),
driver->draw2DImage(imageManager.GetTexture(showcardcode), recti(662 - showcarddif * 0.69685f, 277 - showcarddif, 662 + showcarddif * 0.69685f, 277 + showcarddif),
recti(0, 0, 177, 254), 0, matManager.c2d, true);
if(showcarddif < 127)
showcarddif += 9;
break;
}
case 6: {
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 200));
driver->draw2DImage(imageManager.GetTexture(showcardcode), position2di(574, 150));
driver->draw2DImage(imageManager.tNumber, recti(536 + showcarddif, 191 + showcarddif, 793 - showcarddif, 447 - showcarddif),
recti((showcardp % 5) * 32, (showcardp / 5) * 32, (showcardp % 5 + 1) * 32, (showcardp / 5 + 1) * 32), 0, 0, true);
if(showcarddif < 64)
showcarddif += 4;
break;
}
case 7: {
core::position2d<s32> corner[4];
float y = sin(showcarddif * 3.1415926f / 180.0f) * 254;
corner[0] = core::position2d<s32>(574 - (254 - y) * 0.3f, 404 - y);
corner[1] = core::position2d<s32>(751 + (254 - y) * 0.3f, 404 - y);
corner[2] = core::position2d<s32>(574, 404);
corner[3] = core::position2d<s32>(751, 404);
irr::gui::Draw2DImageQuad(driver, imageManager.GetTexture(showcardcode), rect<s32>(0, 0, 177, 254), corner);
showcardp++;
showcarddif += 9;
if(showcarddif >= 90)
showcarddif = 90;
if(showcardp == 60) {
showcardp = 0;
showcarddif = 0;
}
break;
}
case 100: {
if(showcardp < 60) {
driver->draw2DImage(imageManager.tHand[(showcardcode >> 16) & 0x3], position2di(615, showcarddif));
......
......@@ -50,9 +50,27 @@ bool DuelClient::StartClient(unsigned int ip, unsigned short port, bool create_g
}
connect_state = 1;
rnd.reset(time(0));
if(!create_game) {
timeval timeout = {5, 0};
event* resp_event = event_new(client_base, 0, EV_TIMEOUT, ConnectTimeout, 0);
event_add(resp_event, &timeout);
}
Thread::NewThread(ClientThread, 0);
return true;
}
void DuelClient::ConnectTimeout(evutil_socket_t fd, short events, void* arg) {
if(connect_state == 2)
return;
if(!is_closing) {
mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true);
mainGame->gMutex.Lock();
mainGame->env->addMessageBox(L"", dataManager.GetSysString(1400));
mainGame->gMutex.Unlock();
}
event_base_loopbreak(client_base);
}
void DuelClient::StopClient(bool is_exiting) {
if(connect_state != 2)
return;
......@@ -100,6 +118,7 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
SendPacketToServer(CTOS_CREATE_GAME, cscg);
} else {
CTOS_JoinGame csjg;
csjg.version = PRO_VERSION;
csjg.gameid = 0;
BufferIO::CopyWStr(mainGame->ebJoinPass->getText(), csjg.pass, 20);
SendPacketToServer(CTOS_JOIN_GAME, csjg);
......@@ -201,6 +220,18 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
mainGame->gMutex.Unlock();
break;
}
case ERRMSG_VERERROR: {
mainGame->btnCreateHost->setEnabled(true);
mainGame->btnJoinHost->setEnabled(true);
mainGame->btnJoinCancel->setEnabled(true);
mainGame->gMutex.Lock();
wchar_t msgbuf[256];
myswprintf(msgbuf, dataManager.GetSysString(1411), pkt->code);
mainGame->env->addMessageBox(L"", msgbuf);
mainGame->gMutex.Unlock();
event_base_loopbreak(client_base);
break;
}
}
break;
}
......@@ -1686,7 +1717,8 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
myswprintf(event_string, dataManager.GetSysString(1603), dataManager.GetName(code));
mainGame->showcardcode = code;
mainGame->showcarddif = 0;
mainGame->showcard = 4;
mainGame->showcardp = 0;
mainGame->showcard = 7;
mainGame->WaitFrameSignal(30);
mainGame->showcard = 0;
mainGame->WaitFrameSignal(11);
......@@ -1729,7 +1761,7 @@ int DuelClient::ClientAnalyze(char* msg, unsigned int len) {
mainGame->WaitFrameSignal(11);
mainGame->showcardcode = code;
mainGame->showcarddif = 0;
mainGame->showcard = 4;
mainGame->showcard = 7;
mainGame->WaitFrameSignal(30);
mainGame->showcard = 0;
mainGame->WaitFrameSignal(11);
......
......@@ -34,6 +34,7 @@ private:
static mtrandom rnd;
public:
static bool StartClient(unsigned int ip, unsigned short port, bool create_game = true);
static void ConnectTimeout(evutil_socket_t fd, short events, void* arg);
static void StopClient(bool is_exiting = false);
static void ClientRead(bufferevent* bev, void* ctx);
static void ClientEvent(bufferevent *bev, short events, void *ctx);
......
......@@ -13,7 +13,7 @@
#include <dirent.h>
#endif
const unsigned short PRO_VERSION = 0x1020;
const unsigned short PRO_VERSION = 0x1021;
namespace ygo {
......
......@@ -48,6 +48,7 @@ struct CTOS_CreateGame {
unsigned short pass[20];
};
struct CTOS_JoinGame {
unsigned short version;
unsigned int gameid;
unsigned short pass[20];
};
......@@ -186,6 +187,7 @@ public:
#define ERRMSG_JOINERROR 0x1
#define ERRMSG_DECKERROR 0x2
#define ERRMSG_SIDEERROR 0x3
#define ERRMSG_VERERROR 0x4
#define MODE_SINGLE 0x0
#define MODE_MATCH 0x1
......
......@@ -29,6 +29,13 @@ void SingleDuel::JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {
return;
}
CTOS_JoinGame* pkt = (CTOS_JoinGame*)pdata;
if(pkt->version != PRO_VERSION) {
STOC_ErrorMsg scem;
scem.msg = ERRMSG_VERERROR;
scem.code = PRO_VERSION;
NetServer::SendPacketToPlayer(dp, STOC_ERROR_MSG, scem);
return;
}
wchar_t jpass[20];
BufferIO::CopyWStr(pkt->pass, jpass, 20);
if(wcscmp(jpass, pass)) {
......
......@@ -270,7 +270,6 @@ static const struct luaL_Reg duellib[] = {
{ "GetTurnPlayer", scriptlib::duel_get_turn_player },
{ "GetTurnCount", scriptlib::duel_get_turn_count },
{ "GetDrawCount", scriptlib::duel_get_draw_count },
{ "DebugMessage", scriptlib::duel_debug_message },
{ "RegisterEffect", scriptlib::duel_register_effect },
{ "RegisterFlagEffect", scriptlib::duel_register_flag_effect },
{ "GetFlagEffect", scriptlib::duel_get_flag_effect },
......@@ -447,6 +446,13 @@ static const struct luaL_Reg duellib[] = {
{ NULL, NULL }
};
static const struct luaL_Reg debuglib[] = {
{ "Message", scriptlib::debug_message },
{ "AddCard", scriptlib::debug_add_card },
{ "SetPlayerInfo", scriptlib::debug_set_player_info },
{ NULL, NULL }
};
interpreter::interpreter(duel* pd): coroutines(256) {
lua_state = luaL_newstate();
current_state = lua_state;
......
......@@ -11,7 +11,6 @@
#include "card.h"
#include "effect.h"
#include "group.h"
#include "ocgapi.h"
int32 scriptlib::duel_get_lp(lua_State *L) {
check_param_count(L, 1);
......@@ -55,15 +54,6 @@ int32 scriptlib::duel_get_draw_count(lua_State *L) {
lua_pushinteger(L, pduel->game_field->get_draw_count(playerid));
return 1;
}
int32 scriptlib::duel_debug_message(lua_State *L) {
duel* pduel = interpreter::get_duel_info(L);
lua_getglobal(L, "tostring");
lua_pushvalue(L, -2);
lua_pcall(L, 1, 1, 0);
sprintf(pduel->strbuffer, "%s", lua_tostring(L, -1));
handle_message(pduel, 2);
return 0;
}
int32 scriptlib::duel_register_effect(lua_State *L) {
check_param_count(L, 2);
check_param(L, PARAM_TYPE_EFFECT, 1);
......
......@@ -112,17 +112,19 @@ extern "C" DECL_DLLEXPORT int32 process(ptr pduel) {
}
extern "C" DECL_DLLEXPORT void new_card(ptr pduel, uint32 code, uint8 owner, uint8 playerid, uint8 location, uint8 sequence, uint8 position) {
duel* ptduel = (duel*)pduel;
card* pcard = ptduel->new_card(code);
pcard->owner = owner;
ptduel->game_field->add_card(playerid, pcard, location, sequence);
pcard->current.position = position;
if(!(location & LOCATION_ONFIELD) || (position & POS_FACEUP)) {
pcard->enable_field_effect(TRUE);
ptduel->game_field->adjust_instant();
}
if(location & LOCATION_ONFIELD) {
if(location == LOCATION_MZONE)
pcard->set_status(STATUS_PROC_COMPLETE, TRUE);
if(ptduel->game_field->is_location_useable(playerid, location, sequence)) {
card* pcard = ptduel->new_card(code);
pcard->owner = owner;
ptduel->game_field->add_card(playerid, pcard, location, sequence);
pcard->current.position = position;
if(!(location & LOCATION_ONFIELD) || (position & POS_FACEUP)) {
pcard->enable_field_effect(TRUE);
ptduel->game_field->adjust_instant();
}
if(location & LOCATION_ONFIELD) {
if(location == LOCATION_MZONE)
pcard->set_status(STATUS_PROC_COMPLETE, TRUE);
}
}
}
extern "C" DECL_DLLEXPORT int32 query_card(ptr pduel, uint8 playerid, uint8 location, uint8 sequence, int32 query_flag, byte* buf, int32 use_cache) {
......@@ -246,6 +248,6 @@ extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value) {
extern "C" DECL_DLLEXPORT void set_responseb(ptr pduel, byte* buf) {
((duel*)pduel)->set_responseb(buf);
}
extern "C" DECL_DLLEXPORT void run_script(ptr pduel, byte* scriptbuf, int32 len) {
extern "C" DECL_DLLEXPORT int32 preload_script(ptr pduel, char* script, int32 len) {
return ((duel*)pduel)->lua->load_script(script);
}
......@@ -48,7 +48,7 @@ extern "C" DECL_DLLEXPORT int32 query_field_count(ptr pduel, uint8 playerid, uin
extern "C" DECL_DLLEXPORT int32 query_field_card(ptr pduel, uint8 playerid, uint8 location, int32 query_flag, byte* buf, int32 use_cache);
extern "C" DECL_DLLEXPORT void set_responsei(ptr pduel, int32 value);
extern "C" DECL_DLLEXPORT void set_responseb(ptr pduel, byte* buf);
extern "C" DECL_DLLEXPORT void run_script(ptr pduel, byte* scriptbuf, int32 len);
extern "C" DECL_DLLEXPORT int32 preload_script(ptr pduel, char* script, int32 len);
byte* default_script_reader(const char* script_name, int* len);
uint32 default_card_reader(uint32 code, card_data* data);
uint32 default_message_handler(void* pduel, uint32 msg_type);
......
......@@ -265,7 +265,6 @@ public:
static int32 duel_get_turn_player(lua_State *L);
static int32 duel_get_turn_count(lua_State *L);
static int32 duel_get_draw_count(lua_State *L);
static int32 duel_debug_message(lua_State *L);
static int32 duel_register_effect(lua_State *L);
static int32 duel_register_flag_effect(lua_State *L);
static int32 duel_reset_flag_effect(lua_State *L);
......@@ -445,6 +444,11 @@ public:
static int32 duel_venom_swamp_check(lua_State *L);
static int32 duel_swap_deck_and_grave(lua_State *L);
static int32 duel_majestic_copy(lua_State *L);
//preload
static int32 debug_message(lua_State *L);
static int32 debug_add_card(lua_State *L);
static int32 debug_set_player_info(lua_State *L);
};
#endif /* SCRIPTLIB_H_ */
......@@ -10,7 +10,7 @@ function c33782437.initial_effect(c)
c:RegisterEffect(e1)
end
function c33782437.target(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return Duel.IsPlayerCanDraw(tp,1) and Duel.IsPlayerCanDraw(1-tp) end
if chk==0 then return Duel.IsPlayerCanDraw(tp,1) and Duel.IsPlayerCanDraw(1-tp,1) end
Duel.SetOperationInfo(0,CHAININFO_DRAW,nil,0,PLAYER_ALL,1)
end
function c33782437.activate(e,tp,eg,ep,ev,re,r,rp)
......
......@@ -309,6 +309,7 @@
!system 1408 更换副卡组失败。
!system 1409 等待更换副卡组中...
!system 1410 卡组数量与先前不符合。
!system 1411 版本不匹配(0x%X)。
!system 1500 决斗结束。
!system 1501 录像结束。
!system 1502 连接已断开。
......
textures/negated.png

18 KB | W: | H:

textures/negated.png

31.7 KB | W: | H:

textures/negated.png
textures/negated.png
textures/negated.png
textures/negated.png
  • 2-up
  • Swipe
  • Onion skin
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