X-Git-Url: https://jxself.org/git/?p=informlib.git;a=blobdiff_plain;f=verblib.h;fp=verblib.h;h=c5e73a896628f778739d88604838a7c9ed0bdd9b;hp=e98bb22c1276f21878e1d68da362dd36eee7dd9e;hb=5bfb408b991028b28b411c28971831f59ece4684;hpb=aec9e4131b092ed33213b9891e1dc2b9574edf99 diff --git a/verblib.h b/verblib.h index e98bb22..c5e73a8 100644 --- a/verblib.h +++ b/verblib.h @@ -1,9 +1,9 @@ ! ============================================================================== ! VERBLIB: Front end to standard verbs library. ! -! Supplied for use with Inform 6 -- Release 6.12.3 -- Serial number 190320 +! Supplied for use with Inform 6 -- Release 6.12.4 -- Serial number 200718 ! -! Copyright Graham Nelson 1993-2004 and David Griffith 2012-2019 +! Copyright Graham Nelson 1993-2004 and David Griffith 2012-2020 ! ! This file is free software: you can redistribute it and/or modify ! it under the terms of the GNU Affero General Public License as @@ -54,7 +54,11 @@ Object LibraryMessages; #Ifndef NO_PLACES; [ ObjectsSub; Objects1Sub(); ]; +[ ObjectsTallSub; Objects1TallSub(); ]; +[ ObjectsWideSub; Objects1WideSub(); ]; [ PlacesSub; Places1Sub(); ]; +[ PlacesTallSub; Places1TallSub(); ]; +[ PlacesWideSub; Places1WideSub(); ]; #Endif; ! NO_PLACES ! ------------------------------------------------------------------------------ @@ -79,16 +83,21 @@ Object LibraryMessages; print "^", (string) Story; glk_set_style(style_Normal); #Endif; ! TARGET_ - } + } else + new_line; + if (Headline) print (string) Headline; + else + new_line; + #Ifdef TARGET_ZCODE; - print "Release ", (HDR_GAMERELEASE-->0) & $03ff, " / Serial number "; + print (string) RELEASE__TX, (HDR_GAMERELEASE-->0) & $03ff, " / ", (string) SERNUM__TX; for (i=0 : i<6 : i++) print (char) HDR_GAMESERIAL->i; #Ifnot; ! TARGET_GLULX; - print "Release "; + print (string) RELEASE__TX; @aloads ROM_GAMERELEASE 0 i; print i; - print " / Serial number "; + print " / ", (string) SERNUM__TX; for (i=0 : i<6 : i++) print (char) ROM_GAMESERIAL->i; #Endif; ! TARGET_ new_line; @@ -104,7 +113,7 @@ Object LibraryMessages; #Ifdef TARGET_ZCODE; ix = 0; ! shut up compiler warning if (standard_interpreter > 0) { - print "Standard interpreter ", standard_interpreter/256, ".", standard_interpreter%256, + print (string) STDTERP__TX, standard_interpreter/256, ".", standard_interpreter%256, " (", HDR_TERPNUMBER->0; #Iftrue (#version_number == 6); print (char) '.', HDR_TERPVERSION->0; @@ -114,7 +123,7 @@ Object LibraryMessages; print ") / "; } else { - print "Interpreter ", HDR_TERPNUMBER->0, " Version "; + print (string) TERP__TX, HDR_TERPNUMBER->0, (string) VER__TX; #Iftrue (#version_number == 6); print HDR_TERPVERSION->0; #Ifnot; @@ -125,12 +134,12 @@ Object LibraryMessages; #Ifnot; ! TARGET_GLULX; @gestalt 1 0 ix; - print "Interpreter version ", ix / $10000, ".", (ix & $FF00) / $100, + print (string) TERPVER__TX, ix / $10000, ".", (ix & $FF00) / $100, ".", ix & $FF, " / "; @gestalt 0 0 ix; - print "VM ", ix / $10000, ".", (ix & $FF00) / $100, ".", ix & $FF, " / "; + print (string) VM__TX, ix / $10000, ".", (ix & $FF00) / $100, ".", ix & $FF, " / "; #Endif; ! TARGET_; - print "Library serial number ", (string) LibSerial, "^"; + print (string) LIBSER__TX, (string) LibSerial, "^"; #Ifdef LanguageVersion; print (string) LanguageVersion, "^"; #Endif; ! LanguageVersion @@ -141,36 +150,13 @@ Object LibraryMessages; #Ifdef LanguageError; LanguageError(n, p1, p2); #Ifnot; + + print "** ", (string) LIBERROR__TX, n, " (", p1, ", ", p2, ") **"; #Ifdef DEBUG; - print "** Library error ", n, " (", p1, ", ", p2, ") **^** "; - switch (n) { - 1: print "preposition not found (this should not occur)"; - 2: print "Property value not routine or string: ~", (property) p2, "~ of ~", (name) p1, - "~ (", p1, ")"; - 3: print "Entry in property list not routine or string: ~", (property) p2, "~ list of ~", - (name) p1, "~ (", p1, ")"; - 4: print "Too many timers/daemons are active simultaneously. - The limit is the library constant MAX_TIMERS - (currently ", MAX_TIMERS, ") and should be increased"; - 5: print "Object ~", (name) p1, "~ has no ~", (property) p2, "~ property"; - 7: print "The object ~", (name) p1, "~ can only be used as a player object if it has - the ~number~ property"; - 8: print "Attempt to take random entry from an empty table array"; - 9: print p1, " is not a valid direction property number"; - 10: print "The player-object is outside the object tree"; - 11: print "The room ~", (name) p1, "~ has no ~", (property) p2, "~ property"; - 12: print "Tried to set a non-existent pronoun using SetPronoun"; - 13: print "A 'topic' token can only be followed by a preposition"; - 14: print "Overflowed buffer limit of ", p1, " using '@@64output_stream 3' ", (string) p2; - 15: print "LoopWithinObject broken because the object ", (name) p1, " was moved while the loop passed through it."; - 16: print "Attempt to use illegal narrative_voice of ", p1, "."; - default: - print "(unexplained)"; - } - " **"; - #Ifnot; - "** Library error ", n, " (", p1, ", ", p2, ") **"; - #Endif; ! DEBUG + L__M(##RunTimeError, n, p1, p2); + #Endif; + print "^"; + #Endif; ! LanguageError ]; @@ -347,8 +333,8 @@ Constant ID_BIT $2000; ! Print object id after each entry if (c_style & ISARE_BIT) { if (j == 1 && o hasnt pluralname) Tense(IS__TX, WAS__TX); else Tense(ARE__TX, WERE__TX); - if (c_style & NEWLINE_BIT) print ":^"; - else print (char) ' '; + if (c_style & NEWLINE_BIT) print (string) COLON__TX, "^"; + else print (char) ' '; c_style = c_style - ISARE_BIT; } @@ -414,7 +400,7 @@ Constant ID_BIT $2000; ! Print object id after each entry EnglishNumber(q); print " "; print (string) j.list_together; if (c_style & ENGLISH_BIT) print " ("; - if (c_style & INDENT_BIT) print ":^"; + if (c_style & INDENT_BIT) print (string) COLON__TX, "^"; } q = c_style; if (k2 ~= String) { @@ -520,7 +506,7 @@ Constant ID_BIT $2000; ! Print object id after each entry EnglishNumber(l); print " "; print (string) j.list_together; if (c_style & ENGLISH_BIT) print " ("; - if (c_style & INDENT_BIT) print ":^"; + if (c_style & INDENT_BIT) print (string) COLON__TX, "^"; } q = c_style; if (k ~= String) { @@ -1140,7 +1126,10 @@ Constant ID_BIT $2000; ! Print object id after each entry restore Rmaybe; return L__M(##Restore, 1); .RMaybe; - L__M(##Restore, 2); + if (AfterRestore() == 1) + LibraryExtensions.RunAll(ext_afterrestore); + else + L__M(##Restore, 2); ]; [ SaveSub flag; @@ -1148,16 +1137,26 @@ Constant ID_BIT $2000; ! Print object id after each entry @save -> flag; switch (flag) { 0: L__M(##Save, 1); - 1: L__M(##Save, 2); + 1: + if (AfterSave() == 1) + LibraryExtensions.RunAll(ext_aftersave); + else + L__M(##Save, 2); 2: RestoreColours(); - L__M(##Restore, 2); + if (AfterRestore() == 1) + LibraryExtensions.RunAll(ext_afterrestore); + else + L__M(##Restore, 2); } #Ifnot; save Smaybe; return L__M(##Save, 1); .SMaybe; - L__M(##Save, 2); + if (AfterSave() == 1) + LibraryExtensions.RunAll(ext_aftersave); + else + L__M(##Save, 2); #Endif; ! V5 ]; @@ -1231,7 +1230,7 @@ Constant ID_BIT $2000; ! Print object id after each entry L__M(##Restore, 1); ]; -[ SaveSub res fref; +[ SaveSub res fref retval; fref = glk_fileref_create_by_prompt($01, $01, 0); if (fref == 0) jump SFailed; gg_savestr = glk_stream_open_file(fref, $01, GG_SAVESTR_ROCK); @@ -1246,11 +1245,20 @@ Constant ID_BIT $2000; ! Print object id after each entry GGRecoverObjects(); glk_stream_close(gg_savestr, 0); gg_savestr = 0; - return L__M(##Restore, 2); + if (AfterRestore() == 1) + return LibraryExtensions.RunAll(ext_afterrestore); + else + return L__M(##Restore, 2); + return retval; } glk_stream_close(gg_savestr, 0); gg_savestr = 0; - if (res == 0) return L__M(##Save, 2); + if (res == 0) { + if (AfterSave() == 1) + return LibraryExtensions.RunAll(ext_aftersave); + else + return L__M(##Save, 2); + } .SFailed; L__M(##Save, 1); ]; @@ -1271,7 +1279,6 @@ Constant ID_BIT $2000; ! Print object id after each entry if (gg_scriptstr == 0) jump S1Failed; glk_window_set_echo_stream(gg_mainwin, gg_scriptstr); L__M(##ScriptOn, 2); - VersionSub(); return; .S1Failed; L__M(##ScriptOn, 3); @@ -1326,21 +1333,69 @@ Constant ID_BIT $2000; ! Print object id after each entry [ NotifyOnSub; notify_mode = true; L__M(##NotifyOn); ]; [ NotifyOffSub; notify_mode = false; L__M(##NotifyOff); ]; +[ Places1TallSub; + places_style = NEWLINE_BIT+INDENT_BIT+FULLINV_BIT; + ; +]; + +[ Places1WideSub; + places_style = ENGLISH_BIT+FULLINV_BIT; + ; +]; + [ Places1Sub i j k; - L__M(##Places, 1); objectloop (i has visited) j++; + if (j == 0) + return L__M(##Places, 3); + + L__M(##Places, 1); + if (places_style & INDENT_BIT) print (string) COLON__TX, "^"; + else print " "; + objectloop (i has visited) { + if (places_style & INDENT_BIT) Print__Spaces(2); print (name) i; k++; - if (k == j) return L__M(##Places, 2); - if (k == j-1) print (SerialComma) j, (string) AND__TX; - else print (string) COMMA__TX; + + if (places_style & INDENT_BIT) + new_line; + else { + if (k == j) + return L__M(##Places, 2); + if (k == j-1) + print (SerialComma) j, (string) AND__TX; + else + print (string) COMMA__TX; + } } ]; -[ Objects1Sub i j f; +[ Objects1TallSub; + objects_style = NEWLINE_BIT+INDENT_BIT+FULLINV_BIT; + ; +]; + +[ Objects1WideSub; + objects_style = ENGLISH_BIT+FULLINV_BIT; + ; +]; + +[ Objects1Sub i j f object_count; + object_count = 0; + objectloop (i has moved) { + object_count++; + } + if (object_count == 0) + return L__M(##Objects, 2); + L__M(##Objects, 1); + if (objects_style & INDENT_BIT) print (string) COLON__TX, "^"; + else print " "; + objectloop (i has moved) { - f = 1; print (the) i; j = parent(i); + f++; + if (objects_style & INDENT_BIT) Print__Spaces(2); + print (the) i; + j = parent(i); if (j) { if (j == player) { if (i has worn) L__M(##Objects, 3, j, i); @@ -1357,9 +1412,24 @@ Constant ID_BIT $2000; ! Print object id after each entry .Obj__Ptd; - new_line; + if ((object_count - f) >= 1) { + if (objects_style & INDENT_BIT) { + Print__Spaces(2); + new_line; + } else { + if ((object_count - f) == 1) { + SerialComma(object_count); + print " ", (address) AND1__WD, " "; + } else if (object_count > 2) + print (string) COMMA__TX; + } + } } - if (f == 0) L__M(##Objects, 2); + + if ((objects_style & INDENT_BIT) == 0) + print ".^"; + else + print "^"; ]; ! ---------------------------------------------------------------------------- @@ -1434,7 +1504,6 @@ Constant ID_BIT $2000; ! Print object id after each entry else inventory_style = ENGLISH_BIT+PARTINV_BIT; ; - inventory_style = 0; ]; [ InvTallSub; @@ -1443,7 +1512,6 @@ Constant ID_BIT $2000; ! Print object id after each entry else inventory_style = NEWLINE_BIT+INDENT_BIT+PARTINV_BIT; ; - inventory_style = 0; ]; [ InvSub x; @@ -1773,7 +1841,7 @@ Constant ID_BIT $2000; ! Print object id after each entry if (res >= 2) rtrue; ks = keep_silent; keep_silent = 1; ; keep_silent = ks; if (obj has worn && obj in actor) rtrue; - if (res == 0 && ~~keep_silent) L__M(##Drop, 3, obj); + if (res == 0 && ~~keep_silent) L__M(##Disrobe, 3, obj); rfalse; ]; @@ -1809,10 +1877,11 @@ Constant ID_BIT $2000; ! Print object id after each entry if (noun == actor) return L__M(##PutOn, 4, noun); if (noun in parent(actor)) return L__M(##Drop, 1, noun); if (noun notin actor && ~~ImplicitTake(noun)) return L__M(##Drop, 2, noun); + if (noun has worn && no_implicit_actions) return L__M(##Disrobe, 4, noun); if (noun has worn && ImplicitDisrobe(noun)) return; move noun to parent(actor); if (AfterRoutines() || keep_silent) return; - L__M(##Drop, 4, noun); + L__M(##Drop, 3, noun); ]; [ PutOnSub ancestor; @@ -1929,7 +1998,7 @@ Constant ID_BIT $2000; ! Print object id after each entry } if (k-- == 0) flag = 1; if (flag) break; - if (keep_silent == 0) print (name) i, (string) COLON__TX; + if (keep_silent == 0) print (name) i, (string) COLON__TX, " "; ; i = j; } @@ -1968,7 +2037,12 @@ Constant ID_BIT $2000; ! Print object id after each entry ! ---------------------------------------------------------------------------- [ EnterSub ancestor j ks; - if (noun has door || noun in compass) <>; + if (noun has door || noun in Compass) { + if (verb_word == STAND__TX or SIT__TX or LIE__TX) + return L__M(##Enter, 2, noun, verb_word); + <>; + } + if (actor in noun) return L__M(##Enter, 1, noun); if (noun hasnt enterable) return L__M(##Enter, 2, noun, verb_word); @@ -2065,11 +2139,21 @@ Constant ID_BIT $2000; ! Print object id after each entry } } - thedir = noun.door_dir; - if (metaclass(thedir) == Routine) thedir = RunRoutines(noun, door_dir); + if (noun.door_dir ~= nothing) { + thedir = noun.door_dir; + if (metaclass(thedir) == Routine) + thedir = RunRoutines(noun, door_dir); + next_loc = i.thedir; + } else + next_loc = noun; + + k = metaclass(next_loc); + + if (k == String) { + print (string) next_loc; + new_line; rfalse; + } - next_loc = i.thedir; k = metaclass(next_loc); - if (k == String) { print (string) next_loc; new_line; rfalse; } if (k == Routine) { next_loc = RunRoutines(i, thedir); if (next_loc == 1) rtrue; @@ -2080,6 +2164,7 @@ Constant ID_BIT $2000; ! Print object id after each entry else L__M(##Go, 2); rfalse; } + if (next_loc has door) { if (next_loc has concealed) return L__M(##Go, 2); if (next_loc hasnt open && ImplicitOpen(next_loc)) { @@ -2121,6 +2206,8 @@ Constant ID_BIT $2000; ! Print object id after each entry LookSub(1); ]; + + ! ---------------------------------------------------------------------------- ! Describing the world. SayWhatsOn(object) does just that (producing ! no text if nothing except possibly "scenery" and "concealed" items are). @@ -2129,6 +2216,7 @@ Constant ID_BIT $2000; ! Print object id after each entry ! descriptions as it goes. ! ---------------------------------------------------------------------------- + [ SayWhatsOn descon j f; if (descon == parent(player)) rfalse; objectloop (j in descon) @@ -2137,6 +2225,7 @@ Constant ID_BIT $2000; ! Print object id after each entry L__M(##Look, 4, descon); ]; + [ NotSupportingThePlayer o i; i = parent(player); while (i && i ~= visibility_ceiling) { @@ -2146,70 +2235,113 @@ Constant ID_BIT $2000; ! Print object id after each entry } rtrue; ]; -! modified with the fix for L61122 -[ Locale descin text_without_ALSO text_with_ALSO - o p num_objs must_print_ALSO; - objectloop (o in descin) give o ~workflag; - num_objs = 0; - objectloop (o in descin) - if (o hasnt concealed && NotSupportingThePlayer(o)) { - #Ifndef MANUAL_PRONOUNS; - PronounNotice(o); - #Endif; - if (o has scenery) { - if (o has supporter && child(o)) SayWhatsOn(o); - } - else { - give o workflag; num_objs++; - p = initial; - if ((o has door or container) && o has open && o provides when_open) { - p = when_open; jump Prop_Chosen; - } - if ((o has door or container) && o hasnt open && o provides when_closed) { - p = when_closed; jump Prop_Chosen; - } - if (o has switchable && o has on && o provides when_on) { - p = when_on; jump Prop_Chosen; - } - if (o has switchable && o hasnt on && o provides when_off) { - p = when_off; - } - .Prop_Chosen; - - if (o.&describe && RunRoutines(o, describe)) { - must_print_ALSO = true; - give o ~workflag; num_objs--; - continue; - } - if (o.p && (o hasnt moved || p ~= initial)) { - new_line; - PrintOrRun(o, p); - must_print_ALSO = true; - give o ~workflag; num_objs--; - if (o has supporter && child(o)) SayWhatsOn(o); - } - } - } - if (num_objs == 0) return 0; +! Determine if something is casually visible. Includes things on +! supporters or in open/transparent containers that are scenery. Static +! objects are not included. +[ Locale descin text_without_ALSO text_with_ALSO + o p num_objs must_print_ALSO x flag; + + objectloop (o in descin) { + if (o has scenery && (o has supporter || (o has container && o has open or transparent)) && children(o) > 0) { + flag = 0; + objectloop (x in o) { + if (x hasnt scenery && x hasnt concealed) + flag++; + } + if (flag > 0) { + if (num_objs == 0) + print "^"; + else + print " "; + + if (o has supporter) + print "On ", (the) o; + else + print "In ", (the) o; + + WriteListFrom(child(o), ENGLISH_BIT+TERSE_BIT+CONCEAL_BIT+ISARE_BIT); + print "."; + num_objs++; + } + } + } + + if (num_objs > 0) + print "^"; - if (actor ~= player) give actor concealed; + objectloop (o in descin) + give o ~workflag; + num_objs = 0; + objectloop (o in descin) { + if (o hasnt concealed && NotSupportingThePlayer(o)) { +#Ifndef MANUAL_PRONOUNS; + PronounNotice(o); +#Endif; + if (o hasnt scenery) { + give o workflag; + num_objs++; + p = initial; + if ((o has door or container) && o has open && o provides when_open) { + p = when_open; + jump Prop_Chosen; + } + if ((o has door or container) && o hasnt open && o provides when_closed) { + p = when_closed; + jump Prop_Chosen; + } + if (o has switchable && o has on && o provides when_on) { + p = when_on; + jump Prop_Chosen; + } + if (o has switchable && o hasnt on && o provides when_off) + p = when_off; +.Prop_Chosen; + if (o.&describe && RunRoutines(o, describe)) { + must_print_ALSO = true; + give o ~workflag; + num_objs--; + continue; + } + if (o.p && (o hasnt moved || p ~= initial)) { + new_line; + PrintOrRun(o, p); + must_print_ALSO = true; + give o ~workflag; + num_objs--; + if (o has supporter && child(o)) + SayWhatsOn(o); + } + } + } + } + + if (num_objs == 0) + return 0; + if (actor ~= player) + give actor concealed; if (text_without_ALSO) { - new_line; - if (must_print_ALSO) print (string) text_with_ALSO, " "; - else print (string) text_without_ALSO, " "; - WriteListFrom(child(descin), - ENGLISH_BIT+RECURSE_BIT+PARTINV_BIT+TERSE_BIT+CONCEAL_BIT+WORKFLAG_BIT); - } - else { - if (must_print_ALSO) L__M(##Look, 5, descin); - else L__M(##Look, 6, descin); - } - if (actor ~= player) give actor ~concealed; + new_line; + if (must_print_ALSO) + print (string) text_with_ALSO, " "; + else + print (string) text_without_ALSO, " "; + + WriteListFrom(child(descin), ENGLISH_BIT+RECURSE_BIT+PARTINV_BIT+TERSE_BIT+CONCEAL_BIT+WORKFLAG_BIT); + } else { + if (must_print_ALSO) + L__M(##Look, 5, descin); + else + L__M(##Look, 6, descin); + } + if (actor ~= player) + give actor ~concealed; return num_objs; ]; + + ! ---------------------------------------------------------------------------- ! Looking. LookSub(1) is allowed to abbreviate long descriptions, but ! LookSub(0) (which is what happens when the Look action is generated) @@ -2349,7 +2481,7 @@ Constant ID_BIT $2000; ! Print object id after each entry return L__M(##Examine, 2, noun); } i = PrintOrRun(noun, description); - if (i < 2 && noun has switchable) L__M(##Examine, 3, noun); + if (i == 0 && noun has switchable) L__M(##Examine, 3, noun); AfterRoutines(); ]; @@ -2407,7 +2539,7 @@ Constant ID_BIT $2000; ! Print object id after each entry L__M(##Lock, 5, noun); ]; -[ SwitchonSub; +[ SwitchOnSub; if (ObjectIsUntouchable(noun)) return; if (noun hasnt switchable) return L__M(##SwitchOn, 1, noun); if (noun has on) return L__M(##SwitchOn, 2, noun); @@ -2417,7 +2549,7 @@ Constant ID_BIT $2000; ! Print object id after each entry L__M(##SwitchOn, 3, noun); ]; -[ SwitchoffSub; +[ SwitchOffSub; if (ObjectIsUntouchable(noun)) return; if (noun hasnt switchable) return L__M(##SwitchOff, 1, noun); if (noun hasnt on) return L__M(##SwitchOff, 2, noun); @@ -2492,7 +2624,7 @@ Constant ID_BIT $2000; ! Print object id after each entry ! ---------------------------------------------------------------------------- [ AllowPushDir i; - if (parent(second) ~= compass) return L__M(##PushDir, 2, noun); + if (parent(second) ~= Compass) return L__M(##PushDir, 2, noun); if (second == u_obj or d_obj) return L__M(##PushDir, 3, noun); AfterRoutines(); i = noun; move i to actor; ;