From b668f956411df160f74c42e8cefc4b65c9e33f41 Mon Sep 17 00:00:00 2001 From: nveid Date: Thu, 5 Apr 2007 16:44:01 +0000 Subject: [PATCH] width() and height() take optional second argument for defaults (cherry picked from commit 3a781d24f55fa57590abbff291399e122ad1373e) --- game/txt/changes/0.73 | 1 + game/txt/hlp/cobra_func.hlp | 21 +++++++++++++-------- src/bsd.c | 4 ++++ src/function.c | 4 ++-- 4 files changed, 20 insertions(+), 10 deletions(-) diff --git a/game/txt/changes/0.73 b/game/txt/changes/0.73 index 53eefba..b49e9f5 100644 --- a/game/txt/changes/0.73 +++ b/game/txt/changes/0.73 @@ -174,4 +174,5 @@ CobraMUSH Version 0.73 * Fixed initialization of attribute flags [AEJ] * SQL support is now reported via @config compile. [RLB] * Player aliases may now be supplied to @pemit/list. [RLB] + * Width() and height() take optional second argument for defaults. [RLB] diff --git a/game/txt/hlp/cobra_func.hlp b/game/txt/hlp/cobra_func.hlp index 46840cd..ca03a3d 100644 --- a/game/txt/hlp/cobra_func.hlp +++ b/game/txt/hlp/cobra_func.hlp @@ -4283,23 +4283,28 @@ for an object named "Test", preferring a thing over other types. & HEIGHT() & SCREENWIDTH & SCREENHEIGHT - width() - height() + width([, ]) + height([, ]) These two functions return the screen width and height for a connected player. If the player's client is capable of doing so, it will let the mush know what the correct sizes are on connection and when the client - is resized. The defaults are 78 for width, and 24 for height, the - normal minimal values. These can be changed with the special - SCREENWIDTH and SCREENHEIGHT commands, both of which take a number as - their sole argument, and set the appropriate field. + is resized. - If used on something that's not a player, the functions return the - default values. + The defaults are 78 for width, and 24 for height, the normal minimal + values. These can be overridden when calling the function by + providing the default to the function. Players can change the value + that will be returned when the functions are called on them with the + special SCREENWIDTH and SCREENHEIGHT commands, both of which take a + number as their sole argument, and set the appropriate field. + + When used on something that's not a visible player, the functions + return the default values. The intent of these functions is allow softcode that does formatting to be able to produce a display that can make full use of any given screen size. + & WHERE() where() diff --git a/src/bsd.c b/src/bsd.c index 096e340..e263674 100644 --- a/src/bsd.c +++ b/src/bsd.c @@ -4242,6 +4242,8 @@ FUNCTION(fun_width) safe_str(T("#-1 FUNCTION REQUIRES ONE ARGUMENT"), buff, bp); else if ((match = lookup_desc(executor, args[0]))) safe_integer(match->width, buff, bp); + else if (args[1]) + safe_str(args[1], buff, bp); else safe_str("78", buff, bp); } @@ -4253,6 +4255,8 @@ FUNCTION(fun_height) safe_str(T("#-1 FUNCTION REQUIRES ONE ARGUMENT"), buff, bp); else if ((match = lookup_desc(executor, args[0]))) safe_integer(match->height, buff, bp); + else if (args[1]) + safe_str(args[1], buff, bp); else safe_str("24", buff, bp); } diff --git a/src/function.c b/src/function.c index 7096712..4b98817 100644 --- a/src/function.c +++ b/src/function.c @@ -404,7 +404,7 @@ FUNTAB flist[] = { {"HASPOWER", fun_hasdivpower, 2, 2, FN_REG}, {"HASPOWERGROUP", fun_haspowergroup, 2, 2, FN_REG}, {"HASTYPE", fun_hastype, 2, 2, FN_REG}, - {"HEIGHT", fun_height, 1, 1, FN_REG}, + {"HEIGHT", fun_height, 1, 2, FN_REG}, {"HIDDEN", fun_hidden, 1, 1, FN_REG}, {"HOME", fun_home, 1, 1, FN_REG}, {"HOST", fun_hostname, 1, 1, FN_REG}, @@ -671,7 +671,7 @@ FUNTAB flist[] = { {"VISIBLE", fun_visible, 2, 2, FN_REG}, {"WAIT", fun_wait, 2, 2, FN_NOPARSE}, {"WHERE", fun_where, 1, 1, FN_REG}, - {"WIDTH", fun_width, 1, 1, FN_REG}, + {"WIDTH", fun_width, 1, 2, FN_REG}, {"WILDGREP", fun_grep, 3, 3, FN_REG}, {"WILDGREPI", fun_grep, 3, 3, FN_REG}, {"WIPE", fun_wipe, 1, 1, FN_REG}, -- 2.30.2