Commit 15ed58d5 authored by fallenstardust's avatar fallenstardust

sync ocgcore

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