@hp command crash

Forum rules
NO LONGER BEING MAINTAINED!
Post Reply
joshr45
Posts: 96
Joined: Tue Mar 12, 2013 3:03 pm

@hp command crash

Post by joshr45 » Thu Mar 21, 2013 12:24 am

using @hp without a number crashes the server

PrBlahBlahtson
Developer
Posts: 539
Joined: Sun Jul 22, 2012 12:17 am

Re: @hp command crash

Post by PrBlahBlahtson » Thu Mar 21, 2013 12:53 pm

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.

WiiStream

Re: @hp command crash

Post by WiiStream » Tue Mar 26, 2013 10:13 am

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;
}

PrBlahBlahtson
Developer
Posts: 539
Joined: Sun Jul 22, 2012 12:17 am

Re: @hp command crash

Post by PrBlahBlahtson » Tue Mar 26, 2013 11:45 pm

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.

User avatar
kjLotus
Special Guest
Posts: 1813
Joined: Sun Jul 22, 2012 2:16 pm

Re: @hp command crash

Post by kjLotus » Wed Mar 27, 2013 12:09 am

there's not really much of a point on having a debug break on gm commands

PrBlahBlahtson
Developer
Posts: 539
Joined: Sun Jul 22, 2012 12:17 am

Re: @hp command crash

Post by PrBlahBlahtson » Wed Mar 27, 2013 12:14 am

It's probably on addHP, delHP, or setHP (if there is one.)

User avatar
diatanato
Developer
Posts: 112
Joined: Thu Aug 30, 2012 9:59 pm

Re: @hp command crash

Post by diatanato » Wed Mar 27, 2013 2:44 am

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

Post Reply