MG Mud User | 88f1247 | 2016-06-24 23:31:02 +0200 | [diff] [blame^] | 1 | /* This sefun is to provide a replacement for the efun query_mud_port(). |
| 2 | * Feel free to add it to your mudlibs, if you have much code relying on that. |
| 3 | */ |
| 4 | |
| 5 | #if ! __EFUN_DEFINED__(query_mud_port) |
| 6 | |
| 7 | #include <interactive_info.h> |
| 8 | #include <driver_info.h> |
| 9 | |
| 10 | int query_mud_port(varargs int*|object* args) |
| 11 | { |
| 12 | if(!sizeof(args) && efun::this_player() && efun::interactive(this_player())) |
| 13 | return efun::interactive_info(this_player(), II_MUD_PORT); |
| 14 | |
| 15 | if(sizeof(args) > 1) |
| 16 | raise_error("Too many arguments to query_mud_port\n"); |
| 17 | |
| 18 | if(sizeof(args) && efun::objectp(args[0]) && efun::interactive(args[0])) |
| 19 | return efun::interactive_info(args[0], II_MUD_PORT); |
| 20 | |
| 21 | if(sizeof(args) && intp(args[0])) |
| 22 | { |
| 23 | int* ports = efun::driver_info(DI_MUD_PORTS); |
| 24 | if(args[0] < -1 || args[0] >= sizeof(ports)) |
| 25 | raise_error(efun::sprintf("Bad arg 1 to query_mud_port(): value %d out of range.\n", args[0])); |
| 26 | else if(args[0] == -1) |
| 27 | return sizeof(ports); |
| 28 | else |
| 29 | return ports[args[0]]; |
| 30 | } |
| 31 | |
| 32 | return efun::driver_info(DI_MUD_PORTS)[0]; |
| 33 | } |
| 34 | |
| 35 | #endif |