Commit d62b8735 authored by nanahira's avatar nanahira

Merge branch 'master' into another

parents f83a3c1c 35c37697
No preview for this file type
...@@ -233,6 +233,8 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) { ...@@ -233,6 +233,8 @@ void DuelClient::ClientEvent(bufferevent *bev, short events, void *ctx) {
} }
} }
event_base_loopexit(client_base, 0); event_base_loopexit(client_base, 0);
if(exit_on_return && auto_watch_mode)
mainGame->device->closeDevice();
} }
} }
int DuelClient::ClientThread(void* param) { int DuelClient::ClientThread(void* param) {
......
...@@ -18,10 +18,9 @@ bool ImageManager::Initial() { ...@@ -18,10 +18,9 @@ bool ImageManager::Initial() {
tCover[3] = GetTextureFromFile("textures/cover2.jpg", CARD_IMG_WIDTH, CARD_IMG_HEIGHT); tCover[3] = GetTextureFromFile("textures/cover2.jpg", CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
if(!tCover[3]) if(!tCover[3])
tCover[3] = tCover[2]; tCover[3] = tCover[2];
//tUnknown = NULL; tUnknown = NULL;
tUnknown[0] = NULL; tUnknownFit = NULL;
tUnknown[1] = NULL; tUnknownThumb = NULL;
tUnknown[2] = NULL;
tAct = GetRandomImage(TEXTURE_ACTIVATE); tAct = GetRandomImage(TEXTURE_ACTIVATE);
tAttack = GetRandomImage(TEXTURE_ATTACK); tAttack = GetRandomImage(TEXTURE_ATTACK);
if(!tAct) if(!tAct)
...@@ -135,11 +134,6 @@ void ImageManager::ClearTexture() { ...@@ -135,11 +134,6 @@ void ImageManager::ClearTexture() {
tMap[1].clear(); tMap[1].clear();
tThumb.clear(); tThumb.clear();
tFields.clear(); tFields.clear();
for(int i = 0; i < 3; ++i)
if(tUnknown[i] != NULL) {
driver->removeTexture(tUnknown[i]);
tUnknown[i] = NULL;
}
} }
void ImageManager::RemoveTexture(int code) { void ImageManager::RemoveTexture(int code) {
auto tit = tMap[0].find(code); auto tit = tMap[0].find(code);
...@@ -158,6 +152,11 @@ void ImageManager::RemoveTexture(int code) { ...@@ -158,6 +152,11 @@ void ImageManager::RemoveTexture(int code) {
void ImageManager::ResizeTexture() { void ImageManager::ResizeTexture() {
irr::s32 imgWidth = CARD_IMG_WIDTH * mainGame->xScale; irr::s32 imgWidth = CARD_IMG_WIDTH * mainGame->xScale;
irr::s32 imgHeight = CARD_IMG_HEIGHT * mainGame->yScale; irr::s32 imgHeight = CARD_IMG_HEIGHT * mainGame->yScale;
irr::s32 imgWidthThumb = CARD_THUMB_WIDTH * mainGame->xScale;
irr::s32 imgHeightThumb = CARD_THUMB_HEIGHT * mainGame->yScale;
float mul = (mainGame->xScale > mainGame->yScale) ? mainGame->yScale : mainGame->xScale;
irr::s32 imgWidthFit = CARD_IMG_WIDTH * mul;
irr::s32 imgHeightFit = CARD_IMG_HEIGHT * mul;
irr::s32 bgWidth = 1024 * mainGame->xScale; irr::s32 bgWidth = 1024 * mainGame->xScale;
irr::s32 bgHeight = 640 * mainGame->yScale; irr::s32 bgHeight = 640 * mainGame->yScale;
driver->removeTexture(tCover[0]); driver->removeTexture(tCover[0]);
...@@ -172,8 +171,12 @@ void ImageManager::ResizeTexture() { ...@@ -172,8 +171,12 @@ void ImageManager::ResizeTexture() {
tCover[1] = GetRandomImage(TEXTURE_COVER_S, imgWidth, imgHeight); tCover[1] = GetRandomImage(TEXTURE_COVER_S, imgWidth, imgHeight);
if(!tCover[1]) if(!tCover[1])
tCover[1] = tCover[0]; tCover[1] = tCover[0];
//driver->removeTexture(tUnknown); driver->removeTexture(tUnknown);
//tUnknown = GetTextureFromFile("textures/unknown.jpg", imgWidth, imgHeight); driver->removeTexture(tUnknownFit);
driver->removeTexture(tUnknownThumb);
tUnknown = GetTextureFromFile("textures/unknown.jpg", CARD_IMG_WIDTH, CARD_IMG_HEIGHT);
tUnknownFit = GetTextureFromFile("textures/unknown.jpg", imgWidthFit, imgHeightFit);
tUnknownThumb = GetTextureFromFile("textures/unknown.jpg", imgWidthThumb, imgHeightThumb);
driver->removeTexture(tBackGround); driver->removeTexture(tBackGround);
tBackGround = GetRandomImage(TEXTURE_DUEL, bgWidth, bgHeight); tBackGround = GetRandomImage(TEXTURE_DUEL, bgWidth, bgHeight);
if(!tBackGround) if(!tBackGround)
...@@ -297,11 +300,6 @@ irr::video::ITexture* ImageManager::GetTextureFromFile(char* file, s32 width, s3 ...@@ -297,11 +300,6 @@ irr::video::ITexture* ImageManager::GetTextureFromFile(char* file, s32 width, s3
return driver->getTexture(name); return driver->getTexture(name);
} }
} }
irr::video::ITexture* ImageManager::GetTextureUnknown(s32 width, s32 height, int index) {
if(tUnknown[index] == NULL)
tUnknown[index] = GetTextureFromFile("textures/unknown.jpg", width, height);
return tUnknown[index];
}
irr::video::ITexture* ImageManager::GetTextureExpansions(char* file, s32 width, s32 height) { irr::video::ITexture* ImageManager::GetTextureExpansions(char* file, s32 width, s32 height) {
irr::video::ITexture* img = GetTextureExpansionsDirectry("./expansions", file, width, height); irr::video::ITexture* img = GetTextureExpansionsDirectry("./expansions", file, width, height);
if(img != NULL) if(img != NULL)
...@@ -326,6 +324,8 @@ irr::video::ITexture* ImageManager::GetTextureExpansionsDirectry(const char* pat ...@@ -326,6 +324,8 @@ irr::video::ITexture* ImageManager::GetTextureExpansionsDirectry(const char* pat
return GetTextureFromFile(fpath, width, height); return GetTextureFromFile(fpath, width, height);
} }
irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) { irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
if(code == 0)
return fit ? tUnknownFit : tUnknown;
int width = CARD_IMG_WIDTH; int width = CARD_IMG_WIDTH;
int height = CARD_IMG_HEIGHT; int height = CARD_IMG_HEIGHT;
if(fit) { if(fit) {
...@@ -335,8 +335,6 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) { ...@@ -335,8 +335,6 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
width = width * mul; width = width * mul;
height = height * mul; height = height * mul;
} }
if(code == 0)
return GetTextureUnknown(width, height, fit ? 1 : 0);
auto tit = tMap[fit ? 1 : 0].find(code); auto tit = tMap[fit ? 1 : 0].find(code);
if(tit == tMap[fit ? 1 : 0].end()) { if(tit == tMap[fit ? 1 : 0].end()) {
char file[256]; char file[256];
...@@ -367,19 +365,19 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) { ...@@ -367,19 +365,19 @@ irr::video::ITexture* ImageManager::GetTexture(int code, bool fit) {
return GetTextureThumb(code); return GetTextureThumb(code);
} }
tMap[fit ? 1 : 0][code] = img; tMap[fit ? 1 : 0][code] = img;
return (img == NULL) ? GetTextureUnknown(width, height, fit ? 1 : 0) : img; return (img == NULL) ? (fit ? tUnknownFit : tUnknown) : img;
} }
if(tit->second) if(tit->second)
return tit->second; return tit->second;
else else
return mainGame->gameConf.use_image_scale ? GetTextureUnknown(width, height, fit ? 1 : 0) : GetTextureThumb(code); return mainGame->gameConf.use_image_scale ? (fit ? tUnknownFit : tUnknown) : GetTextureThumb(code);
} }
irr::video::ITexture* ImageManager::GetTextureThumb(int code) { irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
if(code == 0)
return tUnknownThumb;
auto tit = tThumb.find(code); auto tit = tThumb.find(code);
int width = CARD_THUMB_WIDTH * mainGame->xScale; int width = CARD_THUMB_WIDTH * mainGame->xScale;
int height = CARD_THUMB_HEIGHT * mainGame->yScale; int height = CARD_THUMB_HEIGHT * mainGame->yScale;
if(code == 0)
return GetTextureUnknown(width, height, 2);
if(tit == tThumb.end()) { if(tit == tThumb.end()) {
char file[256]; char file[256];
sprintf(file, "pics/thumbnail/%d.png", code); sprintf(file, "pics/thumbnail/%d.png", code);
...@@ -429,12 +427,53 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) { ...@@ -429,12 +427,53 @@ irr::video::ITexture* ImageManager::GetTextureThumb(int code) {
} }
} }
tThumb[code] = img; tThumb[code] = img;
return (img == NULL) ? GetTextureUnknown(width, height, 2) : img; return (img == NULL) ? tUnknownThumb : img;
} }
if(tit->second) if(tit->second)
return tit->second; return tit->second;
else else
return GetTextureUnknown(width, height, 2); return tUnknownThumb;
if(code == 0)
auto tit = tFields.find(code);
if(tit == tFields.end()) {
char file[256];
sprintf(file, "pics/field/%d.png", code);
irr::video::ITexture* img = GetTextureExpansions(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
if(img == NULL) {
sprintf(file, "pics/field/%d.jpg", code);
img = GetTextureExpansions(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
}
if(img == NULL) {
sprintf(file, mainGame->GetLocaleDir("pics/field/%d.png"), code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
}
if(img == NULL) {
sprintf(file, mainGame->GetLocaleDir("pics/field/%d.jpg"), code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
}
if(img == NULL) {
sprintf(file, "pics/field/%d.png", code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
}
if(img == NULL) {
sprintf(file, "pics/field/%d.jpg", code);
img = GetTextureFromFile(file, 512 * mainGame->xScale, 512 * mainGame->yScale);
if(img == NULL) {
tFields[code] = NULL;
return NULL;
} else {
tFields[code] = img;
return img;
}
} else {
tFields[code] = img;
return img;
}
}
if(tit->second)
return tit->second;
else
return NULL;
} }
irr::video::ITexture* ImageManager::GetTextureField(int code) { irr::video::ITexture* ImageManager::GetTextureField(int code) {
if(code == 0) if(code == 0)
......
...@@ -22,7 +22,6 @@ public: ...@@ -22,7 +22,6 @@ public:
void RemoveTexture(int code); void RemoveTexture(int code);
void ResizeTexture(); void ResizeTexture();
irr::video::ITexture* GetTextureFromFile(char* file, s32 width, s32 height); irr::video::ITexture* GetTextureFromFile(char* file, s32 width, s32 height);
irr::video::ITexture* GetTextureUnknown(s32 width, s32 height, int index);
irr::video::ITexture* GetTextureExpansions(char* file, s32 width, s32 height); irr::video::ITexture* GetTextureExpansions(char* file, s32 width, s32 height);
irr::video::ITexture* GetTextureExpansionsDirectry(const char* path, char* file, s32 width, s32 height); irr::video::ITexture* GetTextureExpansionsDirectry(const char* path, char* file, s32 width, s32 height);
irr::video::ITexture* GetTexture(int code, bool fit = false); irr::video::ITexture* GetTexture(int code, bool fit = false);
...@@ -35,7 +34,9 @@ public: ...@@ -35,7 +34,9 @@ public:
irr::IrrlichtDevice* device; irr::IrrlichtDevice* device;
irr::video::IVideoDriver* driver; irr::video::IVideoDriver* driver;
irr::video::ITexture* tCover[4]; irr::video::ITexture* tCover[4];
irr::video::ITexture* tUnknown[3]; irr::video::ITexture* tUnknown;
irr::video::ITexture* tUnknownFit;
irr::video::ITexture* tUnknownThumb;
irr::video::ITexture* tAct; irr::video::ITexture* tAct;
irr::video::ITexture* tAttack; irr::video::ITexture* tAttack;
irr::video::ITexture* tNegated; irr::video::ITexture* tNegated;
......
This diff is collapsed.
Subproject commit cce4df213bf5e928438860478038a0a59d69b846 Subproject commit d1ca9eca73f7361710e525f92130033364e70ad9
Subproject commit 9ace9936831e4f5292173e15a6f4a22e1a46a153 Subproject commit a421e94715beb9e282fb57c1a56eb2f2d2f908dc
...@@ -958,4 +958,4 @@ ...@@ -958,4 +958,4 @@
!setname 0x127 无限起动 無限起動 !setname 0x127 无限起动 無限起動
!setname 0x128 魔女术 ウィッチクラフト !setname 0x128 魔女术 ウィッチクラフト
!setname 0x129 咒眼 呪眼 !setname 0x129 咒眼 呪眼
!setname 0x130 恩底弥翁 !setname 0x12a 恩底弥翁 エンディミオン
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