Commit 40f63398 authored by DailyShana's avatar DailyShana

tweak

parent 96b3763c
...@@ -629,8 +629,8 @@ interpreter::interpreter(duel* pd): coroutines(256) { ...@@ -629,8 +629,8 @@ interpreter::interpreter(duel* pd): coroutines(256) {
luaL_newlib(lua_state, debuglib); luaL_newlib(lua_state, debuglib);
lua_setglobal(lua_state, "Debug"); lua_setglobal(lua_state, "Debug");
//extra scripts //extra scripts
load_script((char*) "./script/constant.lua"); load_script("./script/constant.lua");
load_script((char*) "./script/utility.lua"); load_script("./script/utility.lua");
} }
interpreter::~interpreter() { interpreter::~interpreter() {
lua_close(lua_state); lua_close(lua_state);
...@@ -654,7 +654,7 @@ int32 interpreter::register_card(card *pcard) { ...@@ -654,7 +654,7 @@ int32 interpreter::register_card(card *pcard) {
if(pcard->data.code && (!(pcard->data.type & TYPE_NORMAL) || (pcard->data.type & TYPE_PENDULUM))) { if(pcard->data.code && (!(pcard->data.type & TYPE_NORMAL) || (pcard->data.type & TYPE_PENDULUM))) {
pcard->set_status(STATUS_INITIALIZING, TRUE); pcard->set_status(STATUS_INITIALIZING, TRUE);
add_param(pcard, PARAM_TYPE_CARD); add_param(pcard, PARAM_TYPE_CARD);
call_card_function(pcard, (char*) "initial_effect", 1, 0); call_card_function(pcard, "initial_effect", 1, 0);
pcard->set_status(STATUS_INITIALIZING, FALSE); pcard->set_status(STATUS_INITIALIZING, FALSE);
} }
pcard->cardid = pduel->game_field->infos.card_id++; pcard->cardid = pduel->game_field->infos.card_id++;
...@@ -708,14 +708,14 @@ void interpreter::unregister_group(group *pgroup) { ...@@ -708,14 +708,14 @@ void interpreter::unregister_group(group *pgroup) {
luaL_unref(lua_state, LUA_REGISTRYINDEX, pgroup->ref_handle); luaL_unref(lua_state, LUA_REGISTRYINDEX, pgroup->ref_handle);
pgroup->ref_handle = 0; pgroup->ref_handle = 0;
} }
int32 interpreter::load_script(char* script_name) { int32 interpreter::load_script(const char* script_name) {
int32 error; int32 error;
int32 len = 0; int32 len = 0;
byte* buffer = read_script(script_name, &len); byte* buffer = read_script(script_name, &len);
if (!buffer) if (!buffer)
return OPERATION_FAIL; return OPERATION_FAIL;
no_action++; no_action++;
error = luaL_loadbuffer(current_state, (const char*) buffer, len, (const char*) script_name) || lua_pcall(current_state, 0, 0, 0); error = luaL_loadbuffer(current_state, (char*)buffer, len, script_name) || lua_pcall(current_state, 0, 0, 0);
if (error) { if (error) {
interpreter::strcpy(pduel->strbuffer, lua_tostring(current_state, -1)); interpreter::strcpy(pduel->strbuffer, lua_tostring(current_state, -1));
handle_message(pduel, 1); handle_message(pduel, 1);
...@@ -867,7 +867,7 @@ int32 interpreter::call_function(int32 f, uint32 param_count, int32 ret_count) { ...@@ -867,7 +867,7 @@ int32 interpreter::call_function(int32 f, uint32 param_count, int32 ret_count) {
} }
return OPERATION_SUCCESS; return OPERATION_SUCCESS;
} }
int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count, int32 ret_count) { int32 interpreter::call_card_function(card* pcard, const char* f, uint32 param_count, int32 ret_count) {
if (param_count != params.size()) { if (param_count != params.size()) {
sprintf(pduel->strbuffer, "\"CallCardFunction\"(c%d.%s): incorrect parameter count", pcard->data.code, f); sprintf(pduel->strbuffer, "\"CallCardFunction\"(c%d.%s): incorrect parameter count", pcard->data.code, f);
handle_message(pduel, 1); handle_message(pduel, 1);
...@@ -907,7 +907,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count, ...@@ -907,7 +907,7 @@ int32 interpreter::call_card_function(card* pcard, char* f, uint32 param_count,
} }
return OPERATION_SUCCESS; return OPERATION_SUCCESS;
} }
int32 interpreter::call_code_function(uint32 code, char* f, uint32 param_count, int32 ret_count) { int32 interpreter::call_code_function(uint32 code, const char* f, uint32 param_count, int32 ret_count) {
if (param_count != params.size()) { if (param_count != params.size()) {
sprintf(pduel->strbuffer, "\"CallCodeFunction\": incorrect parameter count"); sprintf(pduel->strbuffer, "\"CallCodeFunction\": incorrect parameter count");
handle_message(pduel, 1); handle_message(pduel, 1);
......
...@@ -49,20 +49,20 @@ public: ...@@ -49,20 +49,20 @@ public:
explicit interpreter(duel* pd); explicit interpreter(duel* pd);
~interpreter(); ~interpreter();
int32 register_card(card *pcard); int32 register_card(card* pcard);
void register_effect(effect* peffect); void register_effect(effect* peffect);
void unregister_effect(effect* peffect); void unregister_effect(effect* peffect);
void register_group(group* pgroup); void register_group(group* pgroup);
void unregister_group(group* pgroup); void unregister_group(group* pgroup);
int32 load_script(char* buffer); int32 load_script(const char* script_name);
int32 load_card_script(uint32 code); int32 load_card_script(uint32 code);
void add_param(void* param, int32 type, bool front = false); void add_param(void* param, int32 type, bool front = false);
void add_param(ptr param, int32 type, bool front = false); void add_param(ptr param, int32 type, bool front = false);
void push_param(lua_State* L, bool is_coroutine = false); void push_param(lua_State* L, bool is_coroutine = false);
int32 call_function(int32 f, uint32 param_count, int32 ret_count); int32 call_function(int32 f, uint32 param_count, int32 ret_count);
int32 call_card_function(card *pcard, char *f, uint32 param_count, int32 ret_count); int32 call_card_function(card* pcard, const char* f, uint32 param_count, int32 ret_count);
int32 call_code_function(uint32 code, char *f, uint32 param_count, int32 ret_count); int32 call_code_function(uint32 code, const char* f, uint32 param_count, int32 ret_count);
int32 check_condition(int32 f, uint32 param_count); int32 check_condition(int32 f, uint32 param_count);
int32 check_matching(card* pcard, int32 findex, int32 extraargs); int32 check_matching(card* pcard, int32 findex, int32 extraargs);
int32 get_operation_value(card* pcard, int32 findex, int32 extraargs); int32 get_operation_value(card* pcard, int32 findex, int32 extraargs);
......
...@@ -10,7 +10,6 @@ ...@@ -10,7 +10,6 @@
#include "common.h" #include "common.h"
#ifdef WIN32 #ifdef WIN32
#include <windows.h>
#define DECL_DLLEXPORT __declspec(dllexport) #define DECL_DLLEXPORT __declspec(dllexport)
#else #else
#define DECL_DLLEXPORT #define DECL_DLLEXPORT
......
...@@ -2034,13 +2034,9 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori ...@@ -2034,13 +2034,9 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori
} }
case 2: { case 2: {
chain newchain; chain newchain;
auto evit = core.point_event.begin(); for(auto evit = core.point_event.begin(); evit != core.instant_event.begin(); ++evit) {
bool pev = true; if(evit == core.point_event.end())
if(evit == core.point_event.end()) {
evit = core.instant_event.begin(); evit = core.instant_event.begin();
pev = false;
}
while(pev || (evit != core.instant_event.end())) {
auto pr = effects.activate_effect.equal_range(evit->event_code); auto pr = effects.activate_effect.equal_range(evit->event_code);
for(auto eit = pr.first; eit != pr.second;) { for(auto eit = pr.first; eit != pr.second;) {
effect* peffect = eit->second; effect* peffect = eit->second;
...@@ -2075,11 +2071,6 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori ...@@ -2075,11 +2071,6 @@ int32 field::process_quick_effect(int16 step, int32 skip_freechain, uint8 priori
core.delayed_quick_break.erase(std::make_pair(peffect, *evit)); core.delayed_quick_break.erase(std::make_pair(peffect, *evit));
} }
} }
++evit;
if(pev && evit == core.point_event.end()) {
evit = core.instant_event.begin();
pev = false;
}
} }
for(auto& ch : core.new_ochain_h) { for(auto& ch : core.new_ochain_h) {
effect* peffect = ch.triggering_effect; effect* peffect = ch.triggering_effect;
......
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