Commit a887c624 authored by Chen Bill's avatar Chen Bill

update class SingleMode

parent ccdba4e7
...@@ -99,7 +99,7 @@ int SingleMode::SinglePlayThread() { ...@@ -99,7 +99,7 @@ int SingleMode::SinglePlayThread() {
mainGame->device->setEventReceiver(&mainGame->dField); mainGame->device->setEventReceiver(&mainGame->dField);
mainGame->gMutex.unlock(); mainGame->gMutex.unlock();
std::vector<char> engineBuffer; std::vector<char> engineBuffer;
engineBuffer.resize(MESSAGE_BUFFER_SIZE); engineBuffer.resize(SIZE_MESSAGE_BUFFER);
is_closing = false; is_closing = false;
is_continuing = true; is_continuing = true;
int len = get_message(pduel, (byte*)engineBuffer.data()); int len = get_message(pduel, (byte*)engineBuffer.data());
...@@ -774,40 +774,36 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) { ...@@ -774,40 +774,36 @@ bool SingleMode::SinglePlayAnalyze(char* msg, unsigned int len) {
} }
return is_continuing; return is_continuing;
} }
void SingleMode::ReloadLocation(int player, int location, int flag, std::vector<unsigned char>& queryBuffer) {
query_field_card(pduel, player, location, flag, queryBuffer.data(), 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(player), location, (char*)queryBuffer.data());
}
void SingleMode::RefreshLocation(int player, int location, int flag) {
std::vector<unsigned char> queryBuffer;
queryBuffer.reserve(SIZE_QUERY_BUFFER);
ReloadLocation(player, location, flag, queryBuffer);
}
void SingleMode::SinglePlayRefresh(int flag) { void SingleMode::SinglePlayRefresh(int flag) {
unsigned char queryBuffer[0x2000]; std::vector<unsigned char> queryBuffer;
/*int len = */query_field_card(pduel, 0, LOCATION_MZONE, flag, queryBuffer, 0); queryBuffer.reserve(SIZE_QUERY_BUFFER);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(0), LOCATION_MZONE, (char*)queryBuffer); ReloadLocation(0, LOCATION_MZONE, flag, queryBuffer);
/*len = */query_field_card(pduel, 1, LOCATION_MZONE, flag, queryBuffer, 0); ReloadLocation(1, LOCATION_MZONE, flag, queryBuffer);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_MZONE, (char*)queryBuffer); ReloadLocation(0, LOCATION_SZONE, flag, queryBuffer);
/*len = */query_field_card(pduel, 0, LOCATION_SZONE, flag, queryBuffer, 0); ReloadLocation(1, LOCATION_SZONE, flag, queryBuffer);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(0), LOCATION_SZONE, (char*)queryBuffer); ReloadLocation(0, LOCATION_HAND, flag, queryBuffer);
/*len = */query_field_card(pduel, 1, LOCATION_SZONE, flag, queryBuffer, 0); ReloadLocation(1, LOCATION_HAND, flag, queryBuffer);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_SZONE, (char*)queryBuffer);
/*len = */query_field_card(pduel, 0, LOCATION_HAND, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(0), LOCATION_HAND, (char*)queryBuffer);
/*len = */query_field_card(pduel, 1, LOCATION_HAND, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_HAND, (char*)queryBuffer);
} }
void SingleMode::SinglePlayRefreshHand(int player, int flag) { void SingleMode::SinglePlayRefreshHand(int player, int flag) {
unsigned char queryBuffer[0x2000]; RefreshLocation(player, LOCATION_HAND, flag);
/*int len = */query_field_card(pduel, player, LOCATION_HAND, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(player), LOCATION_HAND, (char*)queryBuffer);
} }
void SingleMode::SinglePlayRefreshGrave(int player, int flag) { void SingleMode::SinglePlayRefreshGrave(int player, int flag) {
unsigned char queryBuffer[0x2000]; RefreshLocation(player, LOCATION_GRAVE, flag);
/*int len = */query_field_card(pduel, player, LOCATION_GRAVE, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(player), LOCATION_GRAVE, (char*)queryBuffer);
} }
void SingleMode::SinglePlayRefreshDeck(int player, int flag) { void SingleMode::SinglePlayRefreshDeck(int player, int flag) {
unsigned char queryBuffer[0x2000]; RefreshLocation(player, LOCATION_DECK, flag);
/*int len = */query_field_card(pduel, player, LOCATION_DECK, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(player), LOCATION_DECK, (char*)queryBuffer);
} }
void SingleMode::SinglePlayRefreshExtra(int player, int flag) { void SingleMode::SinglePlayRefreshExtra(int player, int flag) {
unsigned char queryBuffer[0x2000]; RefreshLocation(player, LOCATION_EXTRA, flag);
/*int len = */query_field_card(pduel, player, LOCATION_EXTRA, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(player), LOCATION_EXTRA, (char*)queryBuffer);
} }
void SingleMode::SinglePlayRefreshSingle(int player, int location, int sequence, int flag) { void SingleMode::SinglePlayRefreshSingle(int player, int location, int sequence, int flag) {
unsigned char queryBuffer[0x2000]; unsigned char queryBuffer[0x2000];
...@@ -815,36 +811,24 @@ void SingleMode::SinglePlayRefreshSingle(int player, int location, int sequence, ...@@ -815,36 +811,24 @@ void SingleMode::SinglePlayRefreshSingle(int player, int location, int sequence,
mainGame->dField.UpdateCard(mainGame->LocalPlayer(player), location, sequence, (char*)queryBuffer); mainGame->dField.UpdateCard(mainGame->LocalPlayer(player), location, sequence, (char*)queryBuffer);
} }
void SingleMode::SinglePlayReload() { void SingleMode::SinglePlayReload() {
unsigned char queryBuffer[0x2000]; std::vector<byte> queryBuffer;
queryBuffer.reserve(SIZE_QUERY_BUFFER);
unsigned int flag = 0xffdfff; unsigned int flag = 0xffdfff;
/*int len = */query_field_card(pduel, 0, LOCATION_MZONE, flag, queryBuffer, 0); ReloadLocation(0, LOCATION_MZONE, flag, queryBuffer);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(0), LOCATION_MZONE, (char*)queryBuffer); ReloadLocation(1, LOCATION_MZONE, flag, queryBuffer);
/*len = */query_field_card(pduel, 1, LOCATION_MZONE, flag, queryBuffer, 0); ReloadLocation(0, LOCATION_SZONE, flag, queryBuffer);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_MZONE, (char*)queryBuffer); ReloadLocation(1, LOCATION_SZONE, flag, queryBuffer);
/*len = */query_field_card(pduel, 0, LOCATION_SZONE, flag, queryBuffer, 0); ReloadLocation(0, LOCATION_HAND, flag, queryBuffer);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(0), LOCATION_SZONE, (char*)queryBuffer); ReloadLocation(1, LOCATION_HAND, flag, queryBuffer);
/*len = */query_field_card(pduel, 1, LOCATION_SZONE, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_SZONE, (char*)queryBuffer); ReloadLocation(0, LOCATION_DECK, flag, queryBuffer);
/*len = */query_field_card(pduel, 0, LOCATION_HAND, flag, queryBuffer, 0); ReloadLocation(1, LOCATION_DECK, flag, queryBuffer);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(0), LOCATION_HAND, (char*)queryBuffer); ReloadLocation(0, LOCATION_EXTRA, flag, queryBuffer);
/*len = */query_field_card(pduel, 1, LOCATION_HAND, flag, queryBuffer, 0); ReloadLocation(1, LOCATION_EXTRA, flag, queryBuffer);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_HAND, (char*)queryBuffer); ReloadLocation(0, LOCATION_GRAVE, flag, queryBuffer);
/*len = */query_field_card(pduel, 0, LOCATION_DECK, flag, queryBuffer, 0); ReloadLocation(1, LOCATION_GRAVE, flag, queryBuffer);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(0), LOCATION_DECK, (char*)queryBuffer); ReloadLocation(0, LOCATION_REMOVED, flag, queryBuffer);
/*len = */query_field_card(pduel, 1, LOCATION_DECK, flag, queryBuffer, 0); ReloadLocation(1, LOCATION_REMOVED, flag, queryBuffer);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_DECK, (char*)queryBuffer);
/*len = */query_field_card(pduel, 0, LOCATION_EXTRA, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(0), LOCATION_EXTRA, (char*)queryBuffer);
/*len = */query_field_card(pduel, 1, LOCATION_EXTRA, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_EXTRA, (char*)queryBuffer);
/*len = */query_field_card(pduel, 0, LOCATION_GRAVE, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(0), LOCATION_GRAVE, (char*)queryBuffer);
/*len = */query_field_card(pduel, 1, LOCATION_GRAVE, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_GRAVE, (char*)queryBuffer);
/*len = */query_field_card(pduel, 0, LOCATION_REMOVED, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(0), LOCATION_REMOVED, (char*)queryBuffer);
/*len = */query_field_card(pduel, 1, LOCATION_REMOVED, flag, queryBuffer, 0);
mainGame->dField.UpdateFieldCard(mainGame->LocalPlayer(1), LOCATION_REMOVED, (char*)queryBuffer);
} }
int SingleMode::MessageHandler(intptr_t fduel, int type) { int SingleMode::MessageHandler(intptr_t fduel, int type) {
if(!enable_log) if(!enable_log)
......
#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 {
...@@ -18,6 +20,8 @@ public: ...@@ -18,6 +20,8 @@ public:
static int SinglePlayThread(); static int SinglePlayThread();
static bool SinglePlayAnalyze(char* msg, unsigned int len); static bool SinglePlayAnalyze(char* msg, unsigned int len);
inline static void ReloadLocation(int player, int location, int flag, std::vector<unsigned char>& queryBuffer);
inline static void RefreshLocation(int player, int location, int flag);
static void SinglePlayRefresh(int flag = 0xf81fff); static void SinglePlayRefresh(int flag = 0xf81fff);
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);
......
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