Commit 5d2c607b authored by argon.sun's avatar argon.sun

fix

parent 7077d631
...@@ -7,7 +7,7 @@ const wchar_t* DataManager::unknown_string = L"???"; ...@@ -7,7 +7,7 @@ const wchar_t* DataManager::unknown_string = L"???";
wchar_t DataManager::strBuffer[2048]; wchar_t DataManager::strBuffer[2048];
DataManager dataManager; DataManager dataManager;
bool DataManager::LoadDates(const char* file) { bool DataManager::LoadDB(const char* file) {
sqlite3* pDB; sqlite3* pDB;
if(sqlite3_open(file, &pDB) != SQLITE_OK) if(sqlite3_open(file, &pDB) != SQLITE_OK)
return Error(pDB); return Error(pDB);
...@@ -15,8 +15,6 @@ bool DataManager::LoadDates(const char* file) { ...@@ -15,8 +15,6 @@ bool DataManager::LoadDates(const char* file) {
const char* sql = "select * from datas,texts where datas.id=texts.id"; const char* sql = "select * from datas,texts where datas.id=texts.id";
if(sqlite3_prepare_v2(pDB, sql, -1, &pStmt, 0) != SQLITE_OK) if(sqlite3_prepare_v2(pDB, sql, -1, &pStmt, 0) != SQLITE_OK)
return Error(pDB); return Error(pDB);
for(int i = 0; i < 2048; ++i)
_sysStrings[i] = 0;
CardDataC cd; CardDataC cd;
CardString cs; CardString cs;
for(int i = 0; i < 16; ++i) cs.desc[i] = 0; for(int i = 0; i < 16; ++i) cs.desc[i] = 0;
...@@ -63,9 +61,14 @@ bool DataManager::LoadDates(const char* file) { ...@@ -63,9 +61,14 @@ bool DataManager::LoadDates(const char* file) {
} while(step != SQLITE_DONE); } while(step != SQLITE_DONE);
sqlite3_finalize(pStmt); sqlite3_finalize(pStmt);
sqlite3_close(pDB); sqlite3_close(pDB);
FILE* fp = fopen("strings.conf", "r"); return true;
}
bool DataManager::LoadStrings(const char* file) {
FILE* fp = fopen(file, "r");
if(!fp) if(!fp)
return false; return false;
for(int i = 0; i < 2048; ++i)
_sysStrings[i] = 0;
char linebuf[256]; char linebuf[256];
char strbuf[256]; char strbuf[256];
int value; int value;
......
...@@ -11,7 +11,8 @@ namespace ygo { ...@@ -11,7 +11,8 @@ namespace ygo {
class DataManager { class DataManager {
public: public:
DataManager(): _datas(8192), _strings(8192) {} DataManager(): _datas(8192), _strings(8192) {}
bool LoadDates(const char* file); bool LoadDB(const char* file);
bool LoadStrings(const char* file);
bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = 0); bool Error(sqlite3* pDB, sqlite3_stmt* pStmt = 0);
bool GetData(int code, CardData* pData); bool GetData(int code, CardData* pData);
code_pointer GetCodePointer(int code); code_pointer GetCodePointer(int code);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include <dirent.h> #include <dirent.h>
#endif #endif
const unsigned short PRO_VERSION = 0x12e1; const unsigned short PRO_VERSION = 0x12f0;
namespace ygo { namespace ygo {
...@@ -51,7 +51,9 @@ bool Game::Initialize() { ...@@ -51,7 +51,9 @@ bool Game::Initialize() {
imageManager.SetDevice(device); imageManager.SetDevice(device);
if(!imageManager.Initial()) if(!imageManager.Initial())
return false; return false;
if(!dataManager.LoadDates("cards.cdb")) if(!dataManager.LoadDB("cards.cdb"))
return false;
if(!dataManager.LoadStrings("strings.conf"))
return false; return false;
env = device->getGUIEnvironment(); env = device->getGUIEnvironment();
numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16); numFont = irr::gui::CGUITTFont::createTTFont(env, gameConf.numfont, 16);
......
#include "config.h" #include "config.h"
#include "game.h" #include "game.h"
#include "data_manager.h"
#include <event2/thread.h> #include <event2/thread.h>
int enable_log = 0; int enable_log = 0;
...@@ -20,26 +21,28 @@ int main(int argc, char* argv[]) { ...@@ -20,26 +21,28 @@ int main(int argc, char* argv[]) {
if(!ygo::mainGame->Initialize()) if(!ygo::mainGame->Initialize())
return 0; return 0;
if(argc >= 2) { for(int i = 1; i < argc; ++i) {
/*command line args: /*command line args:
* -j: join host (host info from system.conf) * -j: join host (host info from system.conf)
* -d: deck edit * -d: deck edit
* -r: replay */ * -r: replay */
if(!strcmp(argv[1], "-j") || !strcmp(argv[1], "-d") || !strcmp(argv[1], "-r")) { if(argv[i][0] == '-' && argv[i][1] == 'e') {
ygo::dataManager.LoadDB(&argv[i][2]);
} else if(!strcmp(argv[i], "-j") || !strcmp(argv[i], "-d") || !strcmp(argv[i], "-r")) {
exit_on_return = true; exit_on_return = true;
irr::SEvent event; irr::SEvent event;
event.EventType = irr::EET_GUI_EVENT; event.EventType = irr::EET_GUI_EVENT;
event.GUIEvent.EventType = irr::gui::EGET_BUTTON_CLICKED; event.GUIEvent.EventType = irr::gui::EGET_BUTTON_CLICKED;
if(!strcmp(argv[1], "-j")) { if(!strcmp(argv[i], "-j")) {
event.GUIEvent.Caller = ygo::mainGame->btnLanMode; event.GUIEvent.Caller = ygo::mainGame->btnLanMode;
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->device->postEventFromUser(event);
//TODO: wait for wLanWindow show. if network connection faster than wLanWindow, wLanWindow will still show on duel scene. //TODO: wait for wLanWindow show. if network connection faster than wLanWindow, wLanWindow will still show on duel scene.
event.GUIEvent.Caller = ygo::mainGame->btnJoinHost; event.GUIEvent.Caller = ygo::mainGame->btnJoinHost;
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->device->postEventFromUser(event);
} else if(!strcmp(argv[1], "-d")) { } else if(!strcmp(argv[i], "-d")) {
event.GUIEvent.Caller = ygo::mainGame->btnDeckEdit; event.GUIEvent.Caller = ygo::mainGame->btnDeckEdit;
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->device->postEventFromUser(event);
} else if(!strcmp(argv[1], "-r")) { } else if(!strcmp(argv[i], "-r")) {
event.GUIEvent.Caller = ygo::mainGame->btnReplayMode; event.GUIEvent.Caller = ygo::mainGame->btnReplayMode;
ygo::mainGame->device->postEventFromUser(event); ygo::mainGame->device->postEventFromUser(event);
ygo::mainGame->lstReplayList->setSelected(0); ygo::mainGame->lstReplayList->setSelected(0);
......
...@@ -18,6 +18,7 @@ function c19870120.initial_effect(c) ...@@ -18,6 +18,7 @@ function c19870120.initial_effect(c)
local e3=Effect.CreateEffect(c) local e3=Effect.CreateEffect(c)
e3:SetType(EFFECT_TYPE_FIELD) e3:SetType(EFFECT_TYPE_FIELD)
e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET) e3:SetCode(EFFECT_CANNOT_BE_EFFECT_TARGET)
e3:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e3:SetRange(LOCATION_SZONE) e3:SetRange(LOCATION_SZONE)
e3:SetTargetRange(LOCATION_MZONE,0) e3:SetTargetRange(LOCATION_MZONE,0)
e3:SetTarget(c19870120.target) e3:SetTarget(c19870120.target)
...@@ -26,6 +27,7 @@ function c19870120.initial_effect(c) ...@@ -26,6 +27,7 @@ function c19870120.initial_effect(c)
local e4=Effect.CreateEffect(c) local e4=Effect.CreateEffect(c)
e4:SetType(EFFECT_TYPE_FIELD) e4:SetType(EFFECT_TYPE_FIELD)
e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT) e4:SetCode(EFFECT_INDESTRUCTABLE_EFFECT)
e4:SetProperty(EFFECT_FLAG_SET_AVAILABLE)
e4:SetRange(LOCATION_SZONE) e4:SetRange(LOCATION_SZONE)
e4:SetTargetRange(LOCATION_MZONE,0) e4:SetTargetRange(LOCATION_MZONE,0)
e4:SetTarget(c19870120.target) e4:SetTarget(c19870120.target)
......
...@@ -24,7 +24,7 @@ function c21767650.lvtg(e,tp,eg,ep,ev,re,r,rp,chk) ...@@ -24,7 +24,7 @@ function c21767650.lvtg(e,tp,eg,ep,ev,re,r,rp,chk)
end end
function c21767650.lvop(e,tp,eg,ep,ev,re,r,rp) function c21767650.lvop(e,tp,eg,ep,ev,re,r,rp)
local opt=e:GetLabel() local opt=e:GetLabel()
local g=Duel.GetMatchingGroup(c21767650.filter,tp,LOCATION_MZONE,LOCATION_MZONE,nil) local g=Duel.GetMatchingGroup(c21767650.filter,tp,LOCATION_MZONE,0,nil)
local tc=g:GetFirst() local tc=g:GetFirst()
while tc do while tc do
local e1=Effect.CreateEffect(e:GetHandler()) local e1=Effect.CreateEffect(e:GetHandler())
......
...@@ -76,5 +76,5 @@ function c23776077.tgvalue(e,re,rp) ...@@ -76,5 +76,5 @@ function c23776077.tgvalue(e,re,rp)
return rp~=e:GetHandlerPlayer() return rp~=e:GetHandlerPlayer()
end end
function c23776077.indcon(e) function c23776077.indcon(e)
return e:GetHandler():GetOverlayCount()>=5 return e:GetHandler():GetOverlayCount()==5
end end
...@@ -57,8 +57,9 @@ function c23998625.reptg(e,tp,eg,ep,ev,re,r,rp,chk) ...@@ -57,8 +57,9 @@ function c23998625.reptg(e,tp,eg,ep,ev,re,r,rp,chk)
else return false end else return false end
end end
function c23998625.spcon(e,tp,eg,ep,ev,re,r,rp) function c23998625.spcon(e,tp,eg,ep,ev,re,r,rp)
return e:GetHandler():IsReason(REASON_EFFECT) and e:GetHandler():GetOverlayCount()==0 local c=e:GetHandler()
and e:GetHandler():IsLocation(LOCATION_GRAVE) return c:IsPreviousLocation(LOCATION_MZONE) and c:IsReason(REASON_EFFECT) and c:GetOverlayCount()==0
and c:IsLocation(LOCATION_GRAVE)
end end
function c23998625.spfilter(c,e,tp) function c23998625.spfilter(c,e,tp)
return c:IsCode(97403510) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false) return c:IsCode(97403510) and c:IsCanBeSpecialSummoned(e,SUMMON_TYPE_XYZ,tp,false,false)
......
...@@ -20,7 +20,7 @@ function c31863912.initial_effect(c) ...@@ -20,7 +20,7 @@ function c31863912.initial_effect(c)
c:RegisterEffect(e2) c:RegisterEffect(e2)
end end
function c31863912.cfilter(c,sp) function c31863912.cfilter(c,sp)
return c:IsFaceup() and c:GetSummonPlayer()==sp and c:GetLevel()>0 and c:IsAbleToHand() return c:IsFaceup() and c:GetSummonPlayer()==sp
end end
function c31863912.target1(e,tp,eg,ep,ev,re,r,rp,chk) function c31863912.target1(e,tp,eg,ep,ev,re,r,rp,chk)
if chk==0 then return true end if chk==0 then return true end
......
...@@ -16,7 +16,7 @@ function c57836546.condition(e,tp,eg,ep,ev,re,r,rp) ...@@ -16,7 +16,7 @@ function c57836546.condition(e,tp,eg,ep,ev,re,r,rp)
end end
function c57836546.filter1(c,e,tp,turn) function c57836546.filter1(c,e,tp,turn)
return c:IsType(TYPE_XYZ) and c:IsReason(REASON_DESTROY) and c:GetPreviousControler()==tp and c:IsPreviousLocation(LOCATION_MZONE) return c:IsType(TYPE_XYZ) and c:IsReason(REASON_DESTROY) and c:GetPreviousControler()==tp and c:IsPreviousLocation(LOCATION_MZONE)
and c:GetTurnID()==turn and c:IsCanBeSpecialSummoned(e,0,tp,false,false) and c:IsPreviousPosition(POS_FACEUP) and c:GetTurnID()==turn and c:IsCanBeSpecialSummoned(e,0,tp,false,false)
and Duel.IsExistingTarget(c57836546.filter2,tp,LOCATION_GRAVE,0,1,c,e,tp,c:GetAttack()) and Duel.IsExistingTarget(c57836546.filter2,tp,LOCATION_GRAVE,0,1,c,e,tp,c:GetAttack())
end end
function c57836546.filter2(c,e,tp,atk) function c57836546.filter2(c,e,tp,atk)
......
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