Commit 15ed58d5 authored by fallenstardust's avatar fallenstardust

sync ocgcore

update gframe
parent 9ce1584d
...@@ -35,8 +35,12 @@ void ClientCard::SetCode(unsigned int x) { ...@@ -35,8 +35,12 @@ void ClientCard::SetCode(unsigned int x) {
if((location == LOCATION_HAND) && (code != x)) { if((location == LOCATION_HAND) && (code != x)) {
code = x; code = x;
mainGame->dField.MoveCard(this, 5); mainGame->dField.MoveCard(this, 5);
} else } else {
if (x == 0 && code != 0) {
chain_code = code;
}
code = x; code = x;
}
} }
void ClientCard::UpdateInfo(unsigned char* buf) { void ClientCard::UpdateInfo(unsigned char* buf) {
int flag = BufferIO::Read<int32_t>(buf); int flag = BufferIO::Read<int32_t>(buf);
...@@ -48,11 +52,7 @@ void ClientCard::UpdateInfo(unsigned char* buf) { ...@@ -48,11 +52,7 @@ void ClientCard::UpdateInfo(unsigned char* buf) {
int pdata = BufferIO::Read<int32_t>(buf); int pdata = BufferIO::Read<int32_t>(buf);
if (!pdata) if (!pdata)
ClearData(); ClearData();
if((location == LOCATION_HAND) && ((unsigned int)pdata != code)) { SetCode(pdata);
code = pdata;
mainGame->dField.MoveCard(this, 5);
} else
code = pdata;
} }
if(flag & QUERY_POSITION) { if(flag & QUERY_POSITION) {
int pdata = (BufferIO::Read<int32_t>(buf) >> 24) & 0xff; int pdata = (BufferIO::Read<int32_t>(buf) >> 24) & 0xff;
......
...@@ -336,6 +336,7 @@ void Game::DrawCard(ClientCard* pcard) { ...@@ -336,6 +336,7 @@ void Game::DrawCard(ClientCard* pcard) {
if(pcard->aniFrame == 0) { if(pcard->aniFrame == 0) {
pcard->is_moving = false; pcard->is_moving = false;
pcard->is_fading = false; pcard->is_fading = false;
pcard->chain_code = 0;
} }
} }
matManager.mCard.AmbientColor = 0xffffffff; matManager.mCard.AmbientColor = 0xffffffff;
...@@ -343,7 +344,10 @@ void Game::DrawCard(ClientCard* pcard) { ...@@ -343,7 +344,10 @@ void Game::DrawCard(ClientCard* pcard) {
driver->setTransform(irr::video::ETS_WORLD, pcard->mTransform); driver->setTransform(irr::video::ETS_WORLD, pcard->mTransform);
auto m22 = pcard->mTransform(2, 2); auto m22 = pcard->mTransform(2, 2);
if(m22 > -0.99 || pcard->is_moving) { if(m22 > -0.99 || pcard->is_moving) {
matManager.mCard.setTexture(0, imageManager.GetTexture(pcard->code)); auto code = pcard->code;
if (code == 0 && pcard->is_moving)
code = pcard->chain_code;
matManager.mCard.setTexture(0, imageManager.GetTexture(code));
driver->setMaterial(matManager.mCard); driver->setMaterial(matManager.mCard);
driver->drawVertexPrimitiveList(matManager.vCardFront, 4, matManager.iRectangle, 2); driver->drawVertexPrimitiveList(matManager.vCardFront, 4, matManager.iRectangle, 2);
} }
......
...@@ -16,7 +16,7 @@ ...@@ -16,7 +16,7 @@
#include "buffer.h" #include "buffer.h"
duel::duel() { duel::duel() {
lua = new interpreter(this); lua = new interpreter(this, false);
game_field = new field(this); game_field = new field(this);
game_field->temp_card = new_card(TEMP_CARD_ID); game_field->temp_card = new_card(TEMP_CARD_ID);
message_buffer.reserve(SIZE_MESSAGE_BUFFER); message_buffer.reserve(SIZE_MESSAGE_BUFFER);
......
...@@ -14,7 +14,7 @@ ...@@ -14,7 +14,7 @@
#include "ocgapi.h" #include "ocgapi.h"
#include "interpreter.h" #include "interpreter.h"
interpreter::interpreter(duel* pd): coroutines(256) { interpreter::interpreter(duel* pd, bool enable_unsafe_libraries): coroutines(256) {
lua_state = luaL_newstate(); lua_state = luaL_newstate();
current_state = lua_state; current_state = lua_state;
pduel = pd; pduel = pd;
...@@ -32,15 +32,20 @@ interpreter::interpreter(duel* pd): coroutines(256) { ...@@ -32,15 +32,20 @@ interpreter::interpreter(duel* pd): coroutines(256) {
lua_pop(lua_state, 1); lua_pop(lua_state, 1);
luaL_requiref(lua_state, "math", luaopen_math, 1); luaL_requiref(lua_state, "math", luaopen_math, 1);
lua_pop(lua_state, 1); lua_pop(lua_state, 1);
if (enable_unsafe_libraries) {
luaL_requiref(lua_state, "io", luaopen_io, 1);
lua_pop(lua_state, 1);
}
auto nil_out = [&](const char* name) { auto nil_out = [&](const char* name) {
lua_pushnil(lua_state); lua_pushnil(lua_state);
lua_setglobal(lua_state, name); lua_setglobal(lua_state, name);
}; };
nil_out("collectgarbage"); nil_out("collectgarbage");
#ifndef ENABLE_UNSAFE_LIBRARIES if (!enable_unsafe_libraries) {
nil_out("dofile"); nil_out("dofile");
nil_out("loadfile"); nil_out("loadfile");
#endif // ENABLE_UNSAFE_LIBRARIES }
//open all libs //open all libs
scriptlib::open_cardlib(lua_state); scriptlib::open_cardlib(lua_state);
scriptlib::open_effectlib(lua_state); scriptlib::open_effectlib(lua_state);
......
...@@ -51,7 +51,7 @@ public: ...@@ -51,7 +51,7 @@ public:
int32_t no_action; int32_t no_action;
int32_t call_depth; int32_t call_depth;
explicit interpreter(duel* pd); explicit interpreter(duel* pd, bool enable_unsafe_libraries);
~interpreter(); ~interpreter();
void register_card(card* pcard); void register_card(card* pcard);
......
...@@ -176,10 +176,12 @@ int32_t scriptlib::debug_set_ai_name(lua_State *L) { ...@@ -176,10 +176,12 @@ int32_t scriptlib::debug_set_ai_name(lua_State *L) {
} }
int32_t scriptlib::debug_show_hint(lua_State *L) { int32_t scriptlib::debug_show_hint(lua_State *L) {
check_param_count(L, 1); check_param_count(L, 1);
check_param(L, PARAM_TYPE_STRING, 1);
duel* pduel = interpreter::get_duel_info(L); duel* pduel = interpreter::get_duel_info(L);
lua_getglobal(L, "tostring");
lua_pushvalue(L, -2);
lua_pcall(L, 1, 1, 0);
pduel->write_buffer8(MSG_SHOW_HINT); pduel->write_buffer8(MSG_SHOW_HINT);
const char* pstr = lua_tostring(L, 1); const char* pstr = lua_tostring(L, -1);
int len = (int)std::strlen(pstr); int len = (int)std::strlen(pstr);
if (len > SIZE_HINT_MSG - 1) if (len > SIZE_HINT_MSG - 1)
len = SIZE_HINT_MSG - 1; len = SIZE_HINT_MSG - 1;
......
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