Page 1 of 1

@hp command crash

Posted: Thu Mar 21, 2013 12:24 am
by joshr45
using @hp without a number crashes the server

Re: @hp command crash

Posted: Thu Mar 21, 2013 12:53 pm
by PrBlahBlahtson

Code: Select all

DSP_DEBUG_BREAK_IF(lua_isnil(L,-1) || !lua_isnumber(L,-1));
Yup.

Those are scattered all over LUA_baseentity, which is the main connection between the core and scripts. If you pass nulls and you're compiling in debug mode instead of release mode, your server stops so that you can fix the bug.

It's a feature.

Re: @hp command crash

Posted: Tue Mar 26, 2013 10:13 am
by WiiStream
DSP_DEBUG_BREAK_IF(lua_isnil(L,-1) || !lua_isnumber(L,-1));

replace

if(lua_isnil(L,-1) || !lua_isnumber(L,-1))
{
//SHOULD SEND SOME KIND OF MESSAGE TO SERVER CORE OR IN GAME TO YOUR SELF TELLING YOU YOU HAVE A BAD LUA SCRIPT
//ALSO MAYBE SEND THE MESSAGE OF WHAT LUA IT IS!
return false;
}

Re: @hp command crash

Posted: Tue Mar 26, 2013 11:45 pm
by PrBlahBlahtson
The debug breaks are actually there for a reason. They let us know when someone writes a bad script, before it can get beyond the function being called.

Circumventing one because it's inconvenient is pretty much the exact opposite of a good idea.

Re: @hp command crash

Posted: Wed Mar 27, 2013 12:09 am
by kjLotus
there's not really much of a point on having a debug break on gm commands

Re: @hp command crash

Posted: Wed Mar 27, 2013 12:14 am
by PrBlahBlahtson
It's probably on addHP, delHP, or setHP (if there is one.)

Re: @hp command crash

Posted: Wed Mar 27, 2013 2:44 am
by diatanato
WiiStream wrote:DSP_DEBUG_BREAK_IF(lua_isnil(L,-1) || !lua_isnumber(L,-1));

replace

if(lua_isnil(L,-1) || !lua_isnumber(L,-1))
{
//SHOULD SEND SOME KIND OF MESSAGE TO SERVER CORE OR IN GAME TO YOUR SELF TELLING YOU YOU HAVE A BAD LUA SCRIPT
//ALSO MAYBE SEND THE MESSAGE OF WHAT LUA IT IS!
return false;
}
really bad idea. don't try break core if you have bad script

change hp.lua to

Code: Select all

if (type(hp) == "number") then
    if(player:getHP() > 0) then
        player:setHP(hp);
    end 
end