int getdir(boolean s) { char dirsym; if(s) pline("In what direction?"); dirsym = readchar(); if(!movecmd(dirsym) && !u.dz) { if(!strchr(quitchars, dirsym)) pline("What a strange direction!"); return(0); } if(Confusion && !u.dz) confdir(); return(1); }
int getdir(const char *s, schar *dx, schar *dy, schar *dz) { const char *query = s ? s : "In what direction?"; boolean restricted = u.umonnum == PM_GRID_BUG; enum nh_direction dir = (*windowprocs.win_getdir)(query, restricted); log_getdir(dir); *dz = 0; if (!dir_to_delta(dir, dx, dy, dz)) return 0; if (*dx && *dy && u.umonnum == PM_GRID_BUG) { *dx = *dy = 0; return 0; } if (!*dz && (Stunned || (Confusion && !rn2(5)))) confdir(dx, dy); return 1; }
virtual void OnRehash(const std::string ¶m) { if(param != "ssl") return; Conf = new ConfigReader(ServerInstance); for(unsigned int i = 0; i < listenports.size(); i++) { ServerInstance->Config->DelIOHook(listenports[i]); } listenports.clear(); for(int i = 0; i < Conf->Enumerate("bind"); i++) { // For each <bind> tag if(((Conf->ReadValue("bind", "type", i) == "") || (Conf->ReadValue("bind", "type", i) == "clients")) && (Conf->ReadValue("bind", "ssl", i) == "openssl")) { // Get the port we're meant to be listening on with SSL unsigned int port = Conf->ReadInteger("bind", "port", i, true); if (ServerInstance->Config->AddIOHook(port, this)) { // We keep a record of which ports we're listening on with SSL listenports.push_back(port); ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Enabling SSL for port %d", port); } else { ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: FAILED to enable SSL on port %d, maybe you have another ssl or similar module loaded?", port); } } } std::string confdir(CONFIG_FILE); // +1 so we the path ends with a / confdir = confdir.substr(0, confdir.find_last_of('/') + 1); cafile = Conf->ReadValue("openssl", "cafile", 0); // crlfile = Conf->ReadValue("openssl", "crlfile", 0); certfile = Conf->ReadValue("openssl", "certfile", 0); keyfile = Conf->ReadValue("openssl", "keyfile", 0); dhfile = Conf->ReadValue("openssl", "dhfile", 0); // Set all the default values needed. if(cafile == "") cafile = "ca.pem"; //if(crlfile == "") // crlfile = "crl.pem"; if(certfile == "") certfile = "cert.pem"; if(keyfile == "") keyfile = "key.pem"; if(dhfile == "") dhfile = "dhparams.pem"; // Prepend relative paths with the path to the config directory. if(cafile[0] != '/') cafile = confdir + cafile; //if(crlfile[0] != '/') // crlfile = confdir + crlfile; if(certfile[0] != '/') certfile = confdir + certfile; if(keyfile[0] != '/') keyfile = confdir + keyfile; if(dhfile[0] != '/') dhfile = confdir + dhfile; /* Load our keys and certificates*/ if(!SSL_CTX_use_certificate_chain_file(ctx, certfile.c_str())) { ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read certificate file %s", certfile.c_str()); } if(!SSL_CTX_use_PrivateKey_file(ctx, keyfile.c_str(), SSL_FILETYPE_PEM)) { ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read key file %s", keyfile.c_str()); } /* Load the CAs we trust*/ if(!SSL_CTX_load_verify_locations(ctx, cafile.c_str(), 0)) { ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Can't read CA list from ", cafile.c_str()); } FILE* dhpfile = fopen(dhfile.c_str(), "r"); DH* ret; if(dhpfile == NULL) { ServerInstance->Log(DEFAULT, "m_ssl_openssl.so Couldn't open DH file %s: %s", dhfile.c_str(), strerror(errno)); throw ModuleException(); } else { ret = PEM_read_DHparams(dhpfile, NULL, NULL, NULL); if(SSL_CTX_set_tmp_dh(ctx, ret) < 0) { ServerInstance->Log(DEFAULT, "m_ssl_openssl.so: Couldn't set DH parameters"); } } fclose(dhpfile); DELETE(Conf); }
static int use_pick_axe(struct obj *obj) { char dirsyms[12]; extern char sdir[]; char *dsp = dirsyms, *sdp = sdir; struct monst *mtmp; struct rm *lev; int rx, ry, res = 0; if(obj != uwep) { if(uwep && uwep->cursed) { /* Andreas Bormann - ihnp4!decvax!mcvax!unido!ab */ pline("Since your weapon is welded to your hand,"); pline("you cannot use that pick-axe."); return(0); } pline("You now wield %s.", doname(obj)); setuwep(obj); res = 1; } while(*sdp) { (void) movecmd(*sdp); /* sets u.dx and u.dy and u.dz */ rx = u.ux + u.dx; ry = u.uy + u.dy; if(u.dz > 0 || (u.dz == 0 && isok(rx, ry) && (IS_ROCK(levl[rx][ry].typ) || sobj_at(ENORMOUS_ROCK, rx, ry)))) *dsp++ = *sdp; sdp++; } *dsp = 0; pline("In what direction do you want to dig? [%s] ", dirsyms); if(!getdir(0)) /* no txt */ return(res); if(u.uswallow && attack(u.ustuck)) /* return(1) */; else if(u.dz < 0) pline("You cannot reach the ceiling."); else if(u.dz == 0) { if(Confusion) confdir(); rx = u.ux + u.dx; ry = u.uy + u.dy; if((mtmp = m_at(rx, ry)) && attack(mtmp)) return(1); if(!isok(rx, ry)) { pline("Clash!"); return(1); } lev = &levl[rx][ry]; if(lev->typ == DOOR) pline("Your %s against the door.", aobjnam(obj, "clang")); else if(!IS_ROCK(lev->typ) && !sobj_at(ENORMOUS_ROCK, rx, ry)) { /* ACCESSIBLE or POOL */ pline("You swing your %s through thin air.", aobjnam(obj, (char *) 0)); } else { if(dig_pos.x != rx || dig_pos.y != ry || dig_level != dlevel || dig_down) { dig_down = FALSE; dig_pos.x = rx; dig_pos.y = ry; dig_level = dlevel; dig_effort = 0; pline("You start digging."); } else pline("You continue digging."); occupation = dig; occtxt = "digging"; } } else if(Levitation) { pline("You cannot reach the floor."); } else { if(dig_pos.x != u.ux || dig_pos.y != u.uy || dig_level != dlevel || !dig_down) { dig_down = TRUE; dig_pos.x = u.ux; dig_pos.y = u.uy; dig_level = dlevel; dig_effort = 0; pline("You start digging in the floor."); if(inshop()) shopdig(0); } else pline("You continue digging in the floor."); occupation = dig; occtxt = "digging"; } return(1); }