Commit 8d2f4a33 authored by argon.sun's avatar argon.sun

recon

parent 8c3425c4
...@@ -16,6 +16,7 @@ ClientCard::ClientCard() { ...@@ -16,6 +16,7 @@ ClientCard::ClientCard() {
is_showtarget = false; is_showtarget = false;
is_highlighting = false; is_highlighting = false;
is_disabled = false; is_disabled = false;
is_confirming = false;
cmdFlag = 0; cmdFlag = 0;
code = 0; code = 0;
type = 0; type = 0;
......
...@@ -58,6 +58,7 @@ public: ...@@ -58,6 +58,7 @@ public:
bool is_showequip; bool is_showequip;
bool is_showtarget; bool is_showtarget;
bool is_highlighting; bool is_highlighting;
bool is_confirming;
u32 code; u32 code;
u32 alias; u32 alias;
u32 type; u32 type;
......
...@@ -595,9 +595,15 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir ...@@ -595,9 +595,15 @@ void ClientField::GetCardLocation(ClientCard* pcard, irr::core::vector3df* t, ir
t->Y = 4.0f; t->Y = 4.0f;
t->Z = 0.5f + 0.001f * sequence; t->Z = 0.5f + 0.001f * sequence;
} }
r->X = -0.661f; if(!pcard->is_confirming && !pcard->code) {
r->Y = 0.0f; r->X = -0.661f;
r->Z = 0.0f; r->Y = 0.0f;
r->Z = 0.0f;
} else {
r->X = -0.661f;
r->Y = 0;
r->Z = 0;
}
} else { } else {
if (count <= 6) if (count <= 6)
t->X = 6.25f - (5.5f - 0.8f * count) / 2 - sequence * 0.8f; t->X = 6.25f - (5.5f - 0.8f * count) / 2 - sequence * 0.8f;
......
...@@ -242,13 +242,25 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) { ...@@ -242,13 +242,25 @@ void DuelClient::HandleSTOCPacketLan(char* data, unsigned int len) {
} }
break; break;
} }
case STOC_GAME_START: { case STOC_DUEL_START: {
mainGame->gMutex.Lock(); mainGame->gMutex.Lock();
mainGame->dField.Clear(); mainGame->dField.Clear();
mainGame->dInfo.isStarted = true; mainGame->dInfo.isStarted = true;
mainGame->wCardImg->setVisible(true);
mainGame->wInfos->setVisible(true);
mainGame->gMutex.Unlock(); mainGame->gMutex.Unlock();
break; break;
} }
case STOC_DUEL_END: {
break;
}
case STOC_REPLAY: {
mainGame->localAction.Reset();
mainGame->ShowElement(mainGame->wReplaySave);
mainGame->localAction.Wait();
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)
......
...@@ -204,6 +204,16 @@ bool Game::Initialize() { ...@@ -204,6 +204,16 @@ bool Game::Initialize() {
chkAutoChain = env->addCheckBox(false, rect<s32>(20, 80, 280, 105), tabSystem, -1, dataManager.GetSysString(1276)); chkAutoChain = env->addCheckBox(false, rect<s32>(20, 80, 280, 105), tabSystem, -1, dataManager.GetSysString(1276));
chkAutoChain->setChecked(true); chkAutoChain->setChecked(true);
chkWaitChain = env->addCheckBox(false, rect<s32>(20, 110, 280, 135), tabSystem, -1, dataManager.GetSysString(1277)); chkWaitChain = env->addCheckBox(false, rect<s32>(20, 110, 280, 135), tabSystem, -1, dataManager.GetSysString(1277));
//
wHand = env->addWindow(rect<s32>(500, 450, 825, 605), false, L"");
wHand->getCloseButton()->setVisible(false);
wHand->setDraggable(false);
wHand->setDrawTitlebar(false);
wHand->setVisible(false);
for(int i = 0; i < 3; ++i) {
btnHand[i] = env->addButton(rect<s32>(10 + 105 * i, 10, 105 + 105 * i, 144), wHand, BUTTON_HAND1 + i, L"");
btnHand[i]->setImage(imageManager.tHand[i]);
}
//message (310) //message (310)
wMessage = env->addWindow(rect<s32>(490, 200, 840, 340), false, dataManager.GetSysString(1216)); wMessage = env->addWindow(rect<s32>(490, 200, 840, 340), false, dataManager.GetSysString(1216));
wMessage->getCloseButton()->setVisible(false); wMessage->getCloseButton()->setVisible(false);
......
...@@ -218,6 +218,9 @@ public: ...@@ -218,6 +218,9 @@ public:
//replay //replay
irr::gui::IGUIListBox* lstReplayList; irr::gui::IGUIListBox* lstReplayList;
irr::gui::IGUIButton* btnLoadReplay; irr::gui::IGUIButton* btnLoadReplay;
//hand
irr::gui::IGUIWindow* wHand;
irr::gui::IGUIButton* btnHand[3];
//message //message
irr::gui::IGUIWindow* wMessage; irr::gui::IGUIWindow* wMessage;
irr::gui::IGUIStaticText* stMessage; irr::gui::IGUIStaticText* stMessage;
...@@ -362,6 +365,9 @@ extern Game* mainGame; ...@@ -362,6 +365,9 @@ extern Game* mainGame;
#define BUTTON_MSG_OK 200 #define BUTTON_MSG_OK 200
#define BUTTON_YES 201 #define BUTTON_YES 201
#define BUTTON_NO 202 #define BUTTON_NO 202
#define BUTTON_HAND1 205
#define BUTTON_HAND2 206
#define BUTTON_HAND3 207
#define BUTTON_POS_AU 210 #define BUTTON_POS_AU 210
#define BUTTON_POS_AD 211 #define BUTTON_POS_AD 211
#define BUTTON_POS_DU 212 #define BUTTON_POS_DU 212
......
...@@ -17,6 +17,9 @@ bool ImageManager::Initial() { ...@@ -17,6 +17,9 @@ bool ImageManager::Initial() {
tEquip = driver->getTexture("textures/equip.png"); tEquip = driver->getTexture("textures/equip.png");
tTarget = driver->getTexture("textures/target.png"); tTarget = driver->getTexture("textures/target.png");
tLim = driver->getTexture("textures/lim.png"); tLim = driver->getTexture("textures/lim.png");
tHand[0] = driver->getTexture("textures/f1.jpg");
tHand[1] = driver->getTexture("textures/f2.jpg");
tHand[2] = driver->getTexture("textures/f3.jpg");
tBackGround = driver->getTexture("textures/bg.jpg"); tBackGround = driver->getTexture("textures/bg.jpg");
return true; return true;
} }
......
...@@ -32,6 +32,7 @@ public: ...@@ -32,6 +32,7 @@ public:
irr::video::ITexture* tEquip; irr::video::ITexture* tEquip;
irr::video::ITexture* tTarget; irr::video::ITexture* tTarget;
irr::video::ITexture* tLim; irr::video::ITexture* tLim;
irr::video::ITexture* tHand[3];
irr::video::ITexture* tBackGround; irr::video::ITexture* tBackGround;
}; };
......
...@@ -108,14 +108,29 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) { ...@@ -108,14 +108,29 @@ void NetServer::HandleCTOSPacket(DuelPlayer* dp, char* data, unsigned int len) {
if(dp->state == 0xff || (dp->state && dp->state != pktType)) if(dp->state == 0xff || (dp->state && dp->state != pktType))
return; return;
switch(pktType) { switch(pktType) {
case CTOS_RESPONSE: case CTOS_RESPONSE: {
break; break;
}
case CTOS_UPDATE_DECK: { case CTOS_UPDATE_DECK: {
if(!dp->game || !duel_mode) if(!dp->game || !duel_mode)
return; return;
duel_mode->UpdateDeck(dp, pdata); duel_mode->UpdateDeck(dp, pdata);
break; break;
} }
case CTOS_HAND_RESULT: {
if(!dp->game)
return;
CTOS_HandResult* pkt = (CTOS_HandResult*)pdata;
dp->game->HandResult(dp, pkt->res);
break;
}
case CTOS_TP_RESULT: {
if(!dp->game)
return;
CTOS_TPResult* pkt = (CTOS_TPResult*)pdata;
dp->game->TPResult(dp, pkt->res);
break;
}
case CTOS_PLAYER_INFO: { case CTOS_PLAYER_INFO: {
CTOS_PlayerInfo* pkt = (CTOS_PlayerInfo*)pdata; CTOS_PlayerInfo* pkt = (CTOS_PlayerInfo*)pdata;
BufferIO::CopyWStr(pkt->name, dp->name, 20); BufferIO::CopyWStr(pkt->name, dp->name, 20);
......
...@@ -32,6 +32,12 @@ struct HostPacket { ...@@ -32,6 +32,12 @@ struct HostPacket {
struct HostRequest { struct HostRequest {
unsigned short identifier; unsigned short identifier;
}; };
struct CTOS_HandResult {
unsigned char res;
};
struct CTOS_TPResult {
unsigned char res;
};
struct CTOS_PlayerInfo { struct CTOS_PlayerInfo {
unsigned short name[20]; unsigned short name[20];
}; };
...@@ -51,6 +57,10 @@ struct STOC_ErrorMsg { ...@@ -51,6 +57,10 @@ struct STOC_ErrorMsg {
unsigned char msg; unsigned char msg;
unsigned int code; unsigned int code;
}; };
struct STOC_HandResult {
unsigned char res1;
unsigned char res2;
};
struct STOC_CreateGame { struct STOC_CreateGame {
unsigned int gameid; unsigned int gameid;
}; };
...@@ -93,31 +103,23 @@ struct DuelPlayer { ...@@ -93,31 +103,23 @@ struct DuelPlayer {
class DuelMode { class DuelMode {
public: public:
DuelMode() { DuelMode(): host_player(0), pduel(0) {}
for(int i = 0; i < 6; ++i) {
players[i] = 0;
ready[i] = false;
}
host_player = 0;
pduel = 0;
}
virtual ~DuelMode() {} virtual ~DuelMode() {}
virtual void JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) = 0; virtual void JoinGame(DuelPlayer* dp, void* pdata, bool is_creater) {};
virtual void LeaveGame(DuelPlayer* dp) = 0; virtual void LeaveGame(DuelPlayer* dp) {};
virtual void ToDuelist(DuelPlayer* dp) = 0; virtual void ToDuelist(DuelPlayer* dp) {};
virtual void ToObserver(DuelPlayer* dp) = 0; virtual void ToObserver(DuelPlayer* dp) {};
virtual void PlayerReady(DuelPlayer* dp, bool is_ready) = 0; virtual void PlayerReady(DuelPlayer* dp, bool is_ready) {};
virtual void PlayerKick(DuelPlayer* dp, unsigned char pos) = 0; virtual void PlayerKick(DuelPlayer* dp, unsigned char pos) {};
virtual void UpdateDeck(DuelPlayer* dp, void* pdata) = 0; virtual void UpdateDeck(DuelPlayer* dp, void* pdata) {};
virtual void StartDuel(DuelPlayer* dp) = 0; virtual void StartDuel(DuelPlayer* dp) {};
virtual void Process() = 0; virtual void HandResult(DuelPlayer* dp, unsigned char res) {};
virtual void EndDuel() = 0; virtual void TPResult(DuelPlayer* dp, unsigned char tp) {};
virtual void Process() {};
virtual int Analyze(char* msgbuffer, unsigned int len) {};
virtual void EndDuel() {};
public: public:
DuelPlayer* players[6];
bool ready[6];
Deck pdeck[6];
std::set<DuelPlayer*> observers;
DuelPlayer* host_player; DuelPlayer* host_player;
HostInfo host_info; HostInfo host_info;
unsigned long pduel; unsigned long pduel;
...@@ -140,6 +142,8 @@ public: ...@@ -140,6 +142,8 @@ public:
#define CTOS_RESPONSE 0x1 #define CTOS_RESPONSE 0x1
#define CTOS_UPDATE_DECK 0x2 #define CTOS_UPDATE_DECK 0x2
#define CTOS_HAND_RESULT 0x3
#define CTOS_TP_RESULT 0x4
#define CTOS_PLAYER_INFO 0x10 #define CTOS_PLAYER_INFO 0x10
#define CTOS_CREATE_GAME 0x11 #define CTOS_CREATE_GAME 0x11
#define CTOS_JOIN_GAME 0x12 #define CTOS_JOIN_GAME 0x12
...@@ -153,11 +157,17 @@ public: ...@@ -153,11 +157,17 @@ public:
#define STOC_GAME_MSG 0x1 #define STOC_GAME_MSG 0x1
#define STOC_ERROR_MSG 0x2 #define STOC_ERROR_MSG 0x2
#define STOC_SELECT_HAND 0x3
#define STOC_SELECT_TP 0x4
#define STOC_HAND_RESULT 0x5
#define STOC_TP_RESULT 0x6
#define STOC_CREATE_GAME 0x11 #define STOC_CREATE_GAME 0x11
#define STOC_JOIN_GAME 0x12 #define STOC_JOIN_GAME 0x12
#define STOC_TYPE_CHANGE 0x13 #define STOC_TYPE_CHANGE 0x13
#define STOC_LEAVE_GAME 0x14 #define STOC_LEAVE_GAME 0x14
#define STOC_GAME_START 0x15 #define STOC_DUEL_START 0x15
#define STOC_DUEL_END 0x16
#define STOC_REPLAY 0x17
#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
......
This diff is collapsed.
...@@ -3,11 +3,15 @@ ...@@ -3,11 +3,15 @@
#include "config.h" #include "config.h"
#include "network.h" #include "network.h"
#include "Replay.h"
#include "../ocgcore/mtrandom.h"
namespace ygo { namespace ygo {
class SingleDuel: public DuelMode { class SingleDuel: public DuelMode {
public: public:
SingleDuel();
virtual ~SingleDuel();
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);
...@@ -16,9 +20,13 @@ public: ...@@ -16,9 +20,13 @@ public:
virtual void PlayerKick(DuelPlayer* dp, unsigned char pos); virtual void PlayerKick(DuelPlayer* dp, unsigned char pos);
virtual void UpdateDeck(DuelPlayer* dp, void* pdata); virtual void UpdateDeck(DuelPlayer* dp, void* pdata);
virtual void StartDuel(DuelPlayer* dp); virtual void StartDuel(DuelPlayer* dp);
virtual void HandResult(DuelPlayer* dp, unsigned char res);
virtual void TPResult(DuelPlayer* dp, unsigned char tp);
virtual void Process(); virtual void Process();
virtual int Analyze(char* msgbuffer, unsigned int len);
virtual void EndDuel(); virtual void EndDuel();
void WaitforResponse(int playerid);
void RefreshMzone(int player, int flag = 0x181fff, int use_cache = 1); void RefreshMzone(int player, int flag = 0x181fff, int use_cache = 1);
void RefreshSzone(int player, int flag = 0x181fff, int use_cache = 1); void RefreshSzone(int player, int flag = 0x181fff, int use_cache = 1);
void RefreshHand(int player, int flag = 0x181fff, int use_cache = 1); void RefreshHand(int player, int flag = 0x181fff, int use_cache = 1);
...@@ -27,8 +35,16 @@ public: ...@@ -27,8 +35,16 @@ public:
void RefreshSingle(int player, int location, int sequence, int flag = 0x181fff); void RefreshSingle(int player, int location, int sequence, int flag = 0x181fff);
static int MessageHandler(long fduel, int type); static int MessageHandler(long fduel, int type);
protected: protected:
unsigned char player_mapping[2]; DuelPlayer* players[2];
bool ready[2];
Deck pdeck[2];
unsigned char hand_result[2];
unsigned char last_response;
std::set<DuelPlayer*> observers;
Replay last_replay;
mtrandom rnd;
}; };
} }
......
...@@ -442,7 +442,7 @@ static const struct luaL_Reg duellib[] = { ...@@ -442,7 +442,7 @@ static const struct luaL_Reg duellib[] = {
{ NULL, NULL } { NULL, NULL }
}; };
interpreter::interpreter(duel* pd) { interpreter::interpreter(duel* pd): coroutines(256) {
lua_state = luaL_newstate(); lua_state = luaL_newstate();
current_state = lua_state; current_state = lua_state;
pduel = pd; pduel = pd;
......
...@@ -20,7 +20,7 @@ extern "C" { ...@@ -20,7 +20,7 @@ extern "C" {
#endif #endif
} }
#include "common.h" #include "common.h"
#include <map> #include <unordered_map>
#include <list> #include <list>
class card; class card;
...@@ -30,7 +30,7 @@ class duel; ...@@ -30,7 +30,7 @@ class duel;
class interpreter { class interpreter {
public: public:
typedef std::map<int32, lua_State*> coroutine_map; typedef std::unordered_map<int32, lua_State*> coroutine_map;
typedef std::list<std::pair<void*, uint32> > param_list; typedef std::list<std::pair<void*, uint32> > param_list;
duel* pduel; duel* pduel;
......
...@@ -62,14 +62,14 @@ function c47297616.opdisable(e,tp,eg,ep,ev,re,r,rp) ...@@ -62,14 +62,14 @@ function c47297616.opdisable(e,tp,eg,ep,ev,re,r,rp)
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
e1:SetType(EFFECT_TYPE_SINGLE) e1:SetType(EFFECT_TYPE_SINGLE)
e1:SetProperty(EFFECT_FLAG_COPY_INHERIT) e1:SetProperty(EFFECT_FLAG_COPY_INHERIT)
e1:SetReset(RESET_EVENT+RESET_LEAVE+RESET_DISABLE) e1:SetReset(RESET_EVENT+0x1ff0000)
e1:SetCode(EFFECT_UPDATE_ATTACK) e1:SetCode(EFFECT_UPDATE_ATTACK)
e1:SetValue(-500) e1:SetValue(-500)
c:RegisterEffect(e1) c:RegisterEffect(e1)
local e2=Effect.CreateEffect(c) local e2=Effect.CreateEffect(c)
e2:SetType(EFFECT_TYPE_SINGLE) e2:SetType(EFFECT_TYPE_SINGLE)
e2:SetProperty(EFFECT_FLAG_COPY_INHERIT) e2:SetProperty(EFFECT_FLAG_COPY_INHERIT)
e2:SetReset(RESET_EVENT+RESET_LEAVE+RESET_DISABLE) e2:SetReset(RESET_EVENT+0x1ff0000)
e2:SetCode(EFFECT_UPDATE_DEFENCE) e2:SetCode(EFFECT_UPDATE_DEFENCE)
e2:SetValue(-500) e2:SetValue(-500)
c:RegisterEffect(e2) c:RegisterEffect(e2)
...@@ -78,7 +78,7 @@ function c47297616.cdspsum(e) ...@@ -78,7 +78,7 @@ function c47297616.cdspsum(e)
return e:GetHandler():IsReason(REASON_DESTROY) return e:GetHandler():IsReason(REASON_DESTROY)
end end
function c47297616.tgspsum(e,tp,eg,ep,ev,re,r,rp,chk,chkc) function c47297616.tgspsum(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
if chkc then return chkc:GetLocation()==LOCATION_GRAVE and chkc:GetControler()==tp if chkc then return chkc:IsLocation(LOCATION_GRAVE) and chkc:IsControler(tp)
and chkc:IsCanBeSpecialSummoned(e,0,PLAYER_NONE,false,false,POS_FACEUP,tp) end and chkc:IsCanBeSpecialSummoned(e,0,PLAYER_NONE,false,false,POS_FACEUP,tp) end
if chk==0 then return true end if chk==0 then return true end
Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON) Duel.Hint(HINT_SELECTMSG,tp,HINTMSG_SPSUMMON)
...@@ -86,7 +86,7 @@ function c47297616.tgspsum(e,tp,eg,ep,ev,re,r,rp,chk,chkc) ...@@ -86,7 +86,7 @@ function c47297616.tgspsum(e,tp,eg,ep,ev,re,r,rp,chk,chkc)
Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,g:GetCount(),0,0) Duel.SetOperationInfo(0,CATEGORY_SPECIAL_SUMMON,g,g:GetCount(),0,0)
end end
function c47297616.opspsum(e,tp,eg,ep,ev,re,r,rp,chk) function c47297616.opspsum(e,tp,eg,ep,ev,re,r,rp,chk)
local dg=Duel.GetMatchingGroup(aux.TRUE,tp,LOCATION_ONFIELD,0,nil) local dg=Duel.GetMatchingGroup(nil,tp,LOCATION_ONFIELD,0,nil)
Duel.Destroy(dg,REASON_EFFECT) Duel.Destroy(dg,REASON_EFFECT)
local tc=Duel.GetFirstTarget() local tc=Duel.GetFirstTarget()
if tc and tc:IsRelateToEffect(e) then if tc and tc:IsRelateToEffect(e) then
......
--インフェルニティ·デス·ドラゴン --インフェルニティ·デス·ドラゴン
function c72896720.initial_effect(c) function c72896720.initial_effect(c)
--synchro summon --synchro summon
aux.AddSynchroProcedure(c,c72896720.synfilter,aux.NonTuner(c72896720.synfilter),1) aux.AddSynchroProcedure(c,aux.FilterBoolFunction(Card.IsAttribute,ATTRIBUTE_DARK),aux.NonTuner(nil),1)
c:EnableReviveLimit() c:EnableReviveLimit()
--destroy --destroy
local e1=Effect.CreateEffect(c) local e1=Effect.CreateEffect(c)
...@@ -17,9 +17,6 @@ function c72896720.initial_effect(c) ...@@ -17,9 +17,6 @@ function c72896720.initial_effect(c)
e1:SetOperation(c72896720.desop) e1:SetOperation(c72896720.desop)
c:RegisterEffect(e1) c:RegisterEffect(e1)
end end
function c72896720.synfilter(c)
return c:IsAttribute(ATTRIBUTE_DARK)
end
function c72896720.descon(e,tp,eg,ep,ev,re,r,rp) function c72896720.descon(e,tp,eg,ep,ev,re,r,rp)
return Duel.GetFieldGroupCount(tp,LOCATION_HAND,0)==0 return Duel.GetFieldGroupCount(tp,LOCATION_HAND,0)==0
end end
......
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