Skip to content

Commit

Permalink
Unify ignore spawn block with other flags
Browse files Browse the repository at this point in the history
  • Loading branch information
marmichalski committed Aug 29, 2021
1 parent c7cb378 commit 441785b
Show file tree
Hide file tree
Showing 6 changed files with 28 additions and 28 deletions.
2 changes: 1 addition & 1 deletion data/scripts/lib/register_monster_type.lua
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ registerMonsterType.flags = function(mtype, mask)
mtype:isSummonable(mask.flags.summonable)
end
if mask.flags.ignoreSpawnBlock ~= nil then
mtype:ignoresSpawnBlock(mask.flags.ignoreSpawnBlock)
mtype:isIgnoringSpawnBlock(mask.flags.ignoreSpawnBlock)
end
if mask.flags.illusionable ~= nil then
mtype:isIllusionable(mask.flags.illusionable)
Expand Down
36 changes: 18 additions & 18 deletions src/luascript.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2785,11 +2785,11 @@ void LuaScriptInterface::registerFunctions()
registerClass("MonsterType", "", LuaScriptInterface::luaMonsterTypeCreate);
registerMetaMethod("MonsterType", "__eq", LuaScriptInterface::luaUserdataCompare);

registerMethod("MonsterType", "ignoresSpawnBlock", LuaScriptInterface::luaMonsterTypeIgnoresSpawnBlock);
registerMethod("MonsterType", "isAttackable", LuaScriptInterface::luaMonsterTypeIsAttackable);
registerMethod("MonsterType", "isChallengeable", LuaScriptInterface::luaMonsterTypeIsChallengeable);
registerMethod("MonsterType", "isConvinceable", LuaScriptInterface::luaMonsterTypeIsConvinceable);
registerMethod("MonsterType", "isSummonable", LuaScriptInterface::luaMonsterTypeIsSummonable);
registerMethod("MonsterType", "isIgnoringSpawnBlock", LuaScriptInterface::luaMonsterTypeIsIgnoringSpawnBlock);
registerMethod("MonsterType", "isIllusionable", LuaScriptInterface::luaMonsterTypeIsIllusionable);
registerMethod("MonsterType", "isHostile", LuaScriptInterface::luaMonsterTypeIsHostile);
registerMethod("MonsterType", "isPushable", LuaScriptInterface::luaMonsterTypeIsPushable);
Expand Down Expand Up @@ -12970,23 +12970,6 @@ int LuaScriptInterface::luaMonsterTypeCreate(lua_State* L)
return 1;
}

int LuaScriptInterface::luaMonsterTypeIgnoresSpawnBlock(lua_State* L)
{
// get: monsterType:ignoresSpawnBlock() set: monsterType:ignoresSpawnBlock(bool)
MonsterType* monsterType = getUserdata<MonsterType>(L, 1);
if (monsterType) {
if (lua_gettop(L) == 1) {
pushBoolean(L, monsterType->info.ignoresSpawnBlock);
} else {
monsterType->info.ignoresSpawnBlock = getBoolean(L, 2);
pushBoolean(L, true);
}
} else {
lua_pushnil(L);
}
return 1;
}

int LuaScriptInterface::luaMonsterTypeIsAttackable(lua_State* L)
{
// get: monsterType:isAttackable() set: monsterType:isAttackable(bool)
Expand Down Expand Up @@ -13055,6 +13038,23 @@ int LuaScriptInterface::luaMonsterTypeIsSummonable(lua_State* L)
return 1;
}

int LuaScriptInterface::luaMonsterTypeIsIgnoringSpawnBlock(lua_State* L)
{
// get: monsterType:isIgnoringSpawnBlock() set: monsterType:isIgnoringSpawnBlock(bool)
MonsterType* monsterType = getUserdata<MonsterType>(L, 1);
if (monsterType) {
if (lua_gettop(L) == 1) {
pushBoolean(L, monsterType->info.isIgnoringSpawnBlock);
} else {
monsterType->info.isIgnoringSpawnBlock = getBoolean(L, 2);
pushBoolean(L, true);
}
} else {
lua_pushnil(L);
}
return 1;
}

int LuaScriptInterface::luaMonsterTypeIsIllusionable(lua_State* L)
{
// get: monsterType:isIllusionable() set: monsterType:isIllusionable(bool)
Expand Down
2 changes: 1 addition & 1 deletion src/luascript.h
Original file line number Diff line number Diff line change
Expand Up @@ -1283,11 +1283,11 @@ class LuaScriptInterface
// MonsterType
static int luaMonsterTypeCreate(lua_State* L);

static int luaMonsterTypeIgnoresSpawnBlock(lua_State* L);
static int luaMonsterTypeIsAttackable(lua_State* L);
static int luaMonsterTypeIsChallengeable(lua_State* L);
static int luaMonsterTypeIsConvinceable(lua_State* L);
static int luaMonsterTypeIsSummonable(lua_State* L);
static int luaMonsterTypeIsIgnoringSpawnBlock(lua_State* L);
static int luaMonsterTypeIsIllusionable(lua_State* L);
static int luaMonsterTypeIsHostile(lua_State* L);
static int luaMonsterTypeIsPushable(lua_State* L);
Expand Down
2 changes: 1 addition & 1 deletion src/monsters.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -909,7 +909,7 @@ MonsterType* Monsters::loadMonster(const std::string& file, const std::string& m
} else if (strcasecmp(attrName, "hostile") == 0) {
mType->info.isHostile = attr.as_bool();
} else if (strcasecmp(attrName, "ignorespawnblock") == 0) {
mType->info.ignoresSpawnBlock = attr.as_bool();
mType->info.isIgnoringSpawnBlock = attr.as_bool();
} else if (strcasecmp(attrName, "illusionable") == 0) {
mType->info.isIllusionable = attr.as_bool();
} else if (strcasecmp(attrName, "challengeable") == 0) {
Expand Down
12 changes: 6 additions & 6 deletions src/monsters.h
Original file line number Diff line number Diff line change
Expand Up @@ -147,15 +147,15 @@ class MonsterType
bool canPushItems = false;
bool canPushCreatures = false;
bool pushable = true;
bool ignoresSpawnBlock = false;
bool isSummonable = false;
bool isIllusionable = false;
bool isConvinceable = false;
bool isAttackable = true;
bool isHostile = true;
bool hiddenHealth = false;
bool isBoss = false;
bool isChallengeable = true;
bool isConvinceable = false;
bool isHostile = true;
bool isIgnoringSpawnBlock = false;
bool isIllusionable = false;
bool isSummonable = false;
bool hiddenHealth = false;
bool canWalkOnEnergy = true;
bool canWalkOnFire = true;
bool canWalkOnPoison = true;
Expand Down
2 changes: 1 addition & 1 deletion src/spawn.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -294,7 +294,7 @@ bool Spawn::spawnMonster(uint32_t spawnId, spawnBlock_t sb, bool startup/* = fal
MonsterType *mType;
for (std::tuple<MonsterType*, uint16_t> tuple : sb.mTypes) {
mType = std::get<0>(tuple);
if (isBlocked && !mType->info.ignoresSpawnBlock) {
if (isBlocked && !mType->info.isIgnoringSpawnBlock) {
++blockedMonsters;
continue;
}
Expand Down

0 comments on commit 441785b

Please sign in to comment.