Special case player number 1/2 in ApplyGameCommand
This function, oddly, used to take a 1 or 2 for the player number where other nearby functions (e.g. IsPlayerEnabled) would take the proper enum value, 0 or 1. If the old-style syntax (raw number) is used, also use the old-style interpretation.
This commit is contained in:
+10
-1
@@ -2223,8 +2223,17 @@ public:
|
|||||||
static int ApplyGameCommand( T* p, lua_State *L )
|
static int ApplyGameCommand( T* p, lua_State *L )
|
||||||
{
|
{
|
||||||
PlayerNumber pn = PLAYER_INVALID;
|
PlayerNumber pn = PLAYER_INVALID;
|
||||||
if( lua_gettop(L) >= 2 && !lua_isnil(L,2) )
|
if( lua_gettop(L) >= 2 && !lua_isnil(L,2) ) {
|
||||||
|
// Legacy behavior: if an old-style numerical argument
|
||||||
|
// is given, decrement it before trying to parse
|
||||||
|
if( lua_isnumber(L,2) ) {
|
||||||
|
int arg = (int) lua_tonumber( L, 2 );
|
||||||
|
arg--;
|
||||||
|
LuaHelpers::Push( L, arg );
|
||||||
|
lua_replace( L, -2 );
|
||||||
|
}
|
||||||
pn = Enum::Check<PlayerNumber>(L, 2);
|
pn = Enum::Check<PlayerNumber>(L, 2);
|
||||||
|
}
|
||||||
p->ApplyGameCommand(SArg(1),pn);
|
p->ApplyGameCommand(SArg(1),pn);
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user