Skip to content

Commit f722853

Browse files
committed
std_zh: add 'GetLevelSwitchState()'/'SetLevelSwitchState()' helper functions
1 parent e484557 commit f722853

File tree

1 file changed

+17
-0
lines changed

1 file changed

+17
-0
lines changed

resources/include/std_zh/std_functions.zh

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3997,4 +3997,21 @@ lweapon FireLWeaponDir(int type, int x, int y, int dir, int step, int dmg, int s
39973997
return weap;
39983998
}
39993999

4000+
//Gets a switch state for a given level
4001+
bool GetLevelSwitchState(int level, int switchNum)
4002+
{
4003+
if(level < 0 || level >= NUM_LEVELS || switchNum < 0 || switchNum > 31)
4004+
return false;
4005+
return Game->LSwitches[level]&(1Lb<<switchNum);
4006+
}
4007+
4008+
//Sets or unsets a switch state for a given level
4009+
void SetLevelSwitchState(int level, int switchNum, bool state)
4010+
{
4011+
if(level < 0 || level >= NUM_LEVELS) printf("Invalid level (%d) passed to SetLevelSwitchState()\n", level);
4012+
else if(switchNum < 0 || switchNum > 31) printf("Invalid switchNum (%d) passed to SetLevelSwitchState()\n", switchNum);
4013+
else if(state) Game->LSwitches[level] |= (1Lb<<switchNum);
4014+
else Game->LSwitches[level] ~= (1Lb<<switchNum);
4015+
}
4016+
40004017

0 commit comments

Comments
 (0)