CleverRaven / Cataclysm-DDA

Cataclysm - Dark Days Ahead. A turn-based survival game set in a post-apocalyptic world.
http://cataclysmdda.org
Other
10.64k stars 4.18k forks source link

Locked wire gate says "No door there" when tried to open #12210

Closed graysage1 closed 7 years ago

graysage1 commented 9 years ago

It's a misleading message that stumped me for a moment. After I picked the lock, I was able to open the wire gate as usual. I think the message should say something like "This wire gate is locked."

Want to back this issue? Post a bounty on it! We accept bounties via Bountysource.

illi-kun commented 9 years ago

It happens because the function game::open() uses the following piece of code for recognition of the locked door:

 if (terid.find("t_door") != std::string::npos) {
            if (terid.find("_locked") != std::string::npos) {
               add_msg(m_info, _("The door is locked!"));

The most doors have IDs like "t_door_locked_*" but the wire gate doesn't (it's "t_chaingate_l").

So, it's possible to solve this issue by adding another one /if - else/ statement (the easiest but but obviously bad way) or adding new flag LOCKED and using it properly.

graysage1 commented 9 years ago

Supposing you changed the snippet you mention, would the code path toward printing "No door there." still be exercised anyway?

illi-kun commented 9 years ago

If you replace current code around line 7119 of game.cpp by this:

    if (!didit) {
        const std::string terid = m.get_ter(openx, openy);
        if ( (terid.find("t_door") != std::string::npos) || (terid.find("gate") != std::string::npos)) {
            if (terid.find("_l") != std::string::npos) {
                add_msg(m_info, _("You're not able to open the %s!"), m.tername(openx, openy).c_str());
                return;
            } else if (!termap[terid].close.empty() && termap[terid].close != "t_null") {
                // if the following message appears unexpectedly, the prior check was for t_door_o
                add_msg(m_info, _("That door is already open."));
                u.moves += 100;
                return;
            }
        }
        add_msg(m_info, _("No door there."));
        u.moves += 100;
    }

and then try to open the locked wire gate, you'll get this message:

untitled

Text "no door there." can be easily replaced by anything more suitable, of course.

Zireael07 commented 9 years ago

@illi-kun: Please open such a PR!

AlchemistExMachina commented 9 years ago

Even with this fix the gate still won't open. The problem here is that the gates are basically multitile doors. You could have them all open at once like on a car, but the code for multitile doors is vehicle-exclusive. You could have them disappear when a switch is activated, like garage doors, but you'd have to add a lever beside the gate. The gates look like traditional hinge based wire gates with no special devices attached, so the best way to deal with them is write new code for multitile doors that swing open onto multiple tiles. Then there'd be a problem with finding the center of the gate, odd length gates, and whatnot. You could at least make it possible to climb over them.