Commit fd48b607 authored by mercury233's avatar mercury233 Committed by GitHub

Debug.ShowHint support non-string (#747)

* update Debug.ShowHint

support all things which can `tostring`

* fix Debug.Message crash on no param
parent 1bde2fb4
...@@ -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