Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Incorrect Secure safe / Ship Lock code responses
#1
Bug 
I have investigated the lock panels you can install on pods as well as the secure wall safes, and found some odd things.

Assuming that they follow mastermind rules, (which appears to be the intention) the responses from incorrect codes appear to be in error.

Hatch Locking Unit with code 1234:
Sample 1: 6A29 - "The lock panel emits a short boop." From this we conclude that boops indicate that 2 is in the code, but in the wrong place; as expected.
Sample 2: 2361 - "The lock panel emits a short beep and two warbly boops." - Three correct numbers all in the wrong place. confused
Sample 3: 1000 - "The lock panel emits a short beep." One correct number and place, as expected.
Sample 4: 0100 - "The lock panel emits a short beep." confused
Sample 5: 0010 - "The lock panel emits a short beep." confused
Sample 6: 0012 - "The lock panel emits a pair of short beeps." confused
Sample 7: 0210 - "The lock panel emits a short beep and a short boop." That makes sense, nr 2 is in the right place and nr 1 isn't; as expected.
Sample 8: 1200 - "The lock panel emits a pair of short beeps." As expected.
Sample 9: 1020 - "The lock panel emits a pair of short beeps." Wait what? Same response as last, but the 2 is in the wrong spot! confused
Sample 10: 4321 - "The lock panel emits a short beep and a quick three boops." All the numbers are in the wrong spots! confused
Sample 11: 4231 - "The lock panel emits a short beep and a quick three boops." Nr 2 and 3 are in the right spots! confused
Sample 12: 1235 - "The lock panel emits a trio of short beeps." As expected

It doesn't make much sense. So I looked at the published code (Mars 6th).
The secure safe and locking units have identical response code, so I will only go through one of them:
Code:
var/oldcode = code
var/i = 0
var/incode = 0
var/rightplace = 0
while (++i < 5)
    if (copytext(code_attempt, i,i+1) == copytext(oldcode, 1,2))
        rightplace++
        incode++
        oldcode = copytext(oldcode,2)
        continue

    var/foundpoint = findtext(oldcode, copytext(code_attempt,i,i+1))
    if (foundpoint)
        incode++
        oldcode = copytext(oldcode, 1,foundpoint) + copytext(oldcode, foundpoint+1)


Stepping through the code:

code_attempt = "0100"
oldcode = "1234"
i = 0
incode = 0
rightplace = 0

(enter while loop)
i = 1
"0" == "1" = false // Do nothing
foundpoint = 0 (Didn't find "0" in oldcode)

(loop around)
i = 2
"1" == "1" = true // Here's an error. It's testing the second entry in code_attempt against the first entry in oldcode.
rightplace++ = 1 // It's not in the right place though!
incode++ = 1

(skipping the rest here, result is one beep indicating right place and right number)

Code:
switch(incode - rightplace)
    if (1)
        desctext += "a short boop"
    if (2)
        desctext += "two warbly boops"
    if (3)
        desctext += "a quick three boops"
    if (4)
        desctext += "a rather long boop"
Further down you hit this bit, where (4) is supposed to play when you have 4 numbers in the wrong places. This can never be reached as the first incorrect position will be counted as correct. Which leads me to assume that the code is not working as intended.


Messages In This Thread
Incorrect Secure safe / Ship Lock code responses - by VoxSerico - 09-03-2016, 07:07 AM

Forum Jump:


Users browsing this thread: 2 Guest(s)