MCPcopy Index your code
hub / github.com/NetHack/NetHack / doorlock

Function doorlock

src/lock.c:1102–1273  ·  view source on GitHub ↗

Door/secret door was hit with spell or wand effect otmp; returns true if something happened */

Source from the content-addressed store, hash-verified

1100/* Door/secret door was hit with spell or wand effect otmp;
1101 returns true if something happened */
1102boolean
1103doorlock(struct obj *otmp, coordxy x, coordxy y)
1104{
1105 struct rm *door = &levl[x][y];
1106 boolean res = TRUE;
1107 int loudness = 0;
1108 const char *msg = (const char *) 0;
1109 const char *dustcloud = "A cloud of dust";
1110 const char *quickly_dissipates = "quickly dissipates";
1111 boolean mysterywand = (otmp->oclass == WAND_CLASS && !otmp->dknown);
1112
1113 if (door->typ == SDOOR) {
1114 switch (otmp->otyp) {
1115 case WAN_OPENING:
1116 case SPE_KNOCK:
1117 case WAN_STRIKING:
1118 case SPE_FORCE_BOLT:
1119 door->typ = DOOR;
1120 door->doormask = D_CLOSED | (door->doormask & D_TRAPPED);
1121 newsym(x, y);
1122 if (cansee(x, y))
1123 pline("A door appears in the wall!");
1124 if (otmp->otyp == WAN_OPENING || otmp->otyp == SPE_KNOCK)
1125 return TRUE;
1126 break; /* striking: continue door handling below */
1127 case WAN_LOCKING:
1128 case SPE_WIZARD_LOCK:
1129 default:
1130 return FALSE;
1131 }
1132 }
1133
1134 switch (otmp->otyp) {
1135 case WAN_LOCKING:
1136 case SPE_WIZARD_LOCK:
1137 if (Is_rogue_level(&u.uz)) {
1138 boolean vis = cansee(x, y);
1139
1140 /* Can't have real locking in Rogue, so just hide doorway */
1141 if (vis) {
1142 pline("%s springs up in the older, more primitive doorway.",
1143 dustcloud);
1144 } else {
1145 Soundeffect(se_swoosh, 25);
1146 You_hear("a swoosh.");
1147 }
1148 if (obstructed(x, y, mysterywand)) {
1149 if (vis)
1150 pline_The("cloud %s.", quickly_dissipates);
1151 return FALSE;
1152 }
1153 block_point(x, y);
1154 door->typ = SDOOR, door->doormask = D_NODOOR;
1155 if (vis)
1156 pline_The("doorway vanishes!");
1157 newsym(x, y);
1158 return TRUE;
1159 }

Callers 2

bhitFunction · 0.85
mbhitFunction · 0.85

Calls 15

newsymFunction · 0.85
You_hearFunction · 0.85
obstructedFunction · 0.85
pline_TheFunction · 0.85
block_pointFunction · 0.85
t_atFunction · 0.85
canseemonFunction · 0.85
unblock_pointFunction · 0.85
mb_trappedFunction · 0.85
recalc_block_pointFunction · 0.85
vision_recalcFunction · 0.85
wake_neartoFunction · 0.85

Tested by

no test coverage detected