Commit Graph
244 Commits
Author SHA1 Message Date
ac-stef 1b2e944754 add script commands to support texture and sound config menus
textureslotusagelist <what>
  Return a list of 256 numbers representing the number of uses for every
  texture slot. If <what> is "onlygeometry", uses as map model skin do
  not count. If <what> is "onlymodels", the uses in map geometry do not
  count.

gettextureorigin <path>
  Returns the location where the texture actually can be found. The
  possibilities are:
    "official": texture was found in the working directory, which
                indicates an official texture.
    "custom":   texture was found in the profile directory, which means,
                the texture is either manually installed or downloaded.
    "package dir #x": texture was found in a mod directory.
    "<file not found>": that.

textureslotbyname <texture path>
  Returns the list of numbers of all texture slots which use that texture
  file.

edittexturestack <floor|wall|ceiling> <texture slot number>
  Puts a texture slot in a "last used" list up front. The first
  parameter picks the list, the second parameter is the texture
  slot number to be used for the next edit

getautomapconfig
  Returns "1" if automapconfig is already enabled, "0" otherwise.

getmapsoundorigin <path>
  Returns the location where the map sound file actually can be found. The
  possibilities are:
    "official": the sound file was found in the working directory, which
                indicates an official mapsound.
    "custom":   the file was found in the profile directory, which means,
                the mapsound is either manually installed or downloaded.
    "package dir #x": mapsound was found in a mod directory.
    "<file not found>": that.

mapsoundslotbyname <mapsound path>
  Returns the list of numbers of all mapsound slots which use that texture
  file.

getmapsoundlist
  Returns a list of all *.wav and *.ogg files below packages/audio/ambient.

DOCREF textureslotusagelist gettextureorigin textureslotbyname
DOCREF edittexturestack getautomapconfig
DOCREF getmapsoundorigin mapsoundslotbyname getmapsoundlist
2015-06-05 16:00:02 +02:00
ac-stef 07facdfcc2 fix: no snprintf on VS 2015-05-27 15:47:04 +02:00
ac-stef c4e1155dcc option to write floats as ints when possible
omit the ".0" in values like "3.0"
2015-05-18 14:59:41 +02:00
ac-stef e5fc8b35a2 be extremely pedantic with setvar and getvar in debug mode
This will exit the program, if code tries to access a non-existing
variable or an existing variable of the wrong type.
2015-05-18 14:59:41 +02:00
ac-stef 03bcae1918 make sure that COMMAND arguments are always in a writeable segment
Casting a string constant to "char *" causes segfaults if a command tries
to write to it. Now, empty strings are rarely written to, but it is
inconsistent, if command arguments change memory segments depending on the
argument value.
2015-05-18 14:46:03 +02:00
ac-stef 03f974b2bc additional text attributes for mapmodels
This adds a means to store additional attributes for mapmodels, including
a caching mechanism, so the mapmodels don't have to be loaded to access
the information. The goal is, to provide fully automatic mapmodel menus
for map editing who also add information about downloaded mapmodels.

Model attributes are extracted everytime, when a model is loaded. At game
end, all available data is written to config/mapmodelattributes.cfg and
restored at next startup. On release, a file with all (but only) official
models should be included. Since autodownloaded models are usually "loaded"
after download, those are automatically added to the database. If someone
adds models manually to the directories (media pack, w/e), the command
"loadallmapmodels" can be used to try to find all available models. The
only way to delete something from the database, is to delete the file
config/mapmodelattributes.cfg when the game is closed.

The current list of attributes is:

keywords
  List of one or more menu topics to list the model under. Check
  config/menus_edit.cfg for available keywords. Unknown keywords will
  be listed separately.

desc
  Short name or description of the model. Will be used as menu entry.

usage
  Important information for how to use that specific model.

author
  Who created the mapmodel. If it's a derivative of another model, state
  the author of the mod (refer to the original author under "license", if
  you like). Always use the exact same spelling for the same author, to
  allow menus to automatically group models by author.

license
  Free-text attribute for license info or info about additional
  contributors (or original authors for derivated works).

distribution
  One of "official", "autodownload" or "manual". Other values default to
  "manual". This is used to determine, if a map contains only original
  media or media that can be download automatically.

version
  Single numerical value to separate older from newer versions. Defaults
  to zero. Higher numbers mean "newer". Maybe someone manages to implement
  a versioning system for custom media in the future...

New commands:

mdlattribute <attr> <value>
  To be used in model config files. Adds a value for a specified
  attribute to the model.

mapmodelregister <modelpath> <attr1> <attr2> ...
  Adds values for all attributes to a specific mapmodel. This is used to
  restore the cached values from config/mapmodelattributes.cfg during
  game start. Does not actually verify of load the model.

mapmodelattributes <modelpath> <attr>
  Returns the value of a specific attribute of a mapmodel. If modelpath
  is a number, it is interpreted as index for the list of models in the
  current map config. If no attribute name is specified, all attributes
  are printed to the console instead.

getmapmodelattributes <list of attribute names>
  Returns a table of all known mapmodels. Each model is listed with the
  modelpath and the values for the requested attributes. To be used
  instead of a fixed table in menu_edit.cfg. In addition to attribute
  names, the function also allows the keywords "explodekeywords" and
  "sortby:" as arguments. If "explodekeywords" is given, all mapmodels
  with more than one keyword are listed multiple times, once for each
  keyword. If an attribute name is preceeded by "sortby:" the list will
  be sorted by this table column. If "sortby:" is used several times,
  this first sort will have highest priority. The list is always sorted
  by path by default.

  example:
    getmapmodelattributes sortby: author sortby: desc explodekeywords

loadallmapmodels
  Tries to load mapmodels from /all/ paths below packages/models/mapmodels.
  Will throw a lot of error messages, because not all directories contain
  models to load. This command can be used to build or rebuild the
  complete list of all available mapmodels. It is only necessary, if models
  are added manually to the directories, since every mapmodel gets added
  to the list when it is loaded - which takes care of all automatically
  downloaded models.

DOCREF mdlattribute mapmodelregister mapmodelattributes
DOCREF getmapmodelattributes loadallmapmodels
2015-05-17 00:24:38 +02:00
ac-stef f86e2c1f4a fix loadcrosshair script in saved.cfg
"c" is already used as "const" and therefore is not allowed as temporary
alias...
2015-05-17 00:24:38 +02:00
ac-stef d55dbb47f4 output error message when temporary alias can not be created 2015-05-17 00:24:38 +02:00
ac-stef 3e84f11630 cleanup 2015-05-17 00:24:38 +02:00
aurhat b2da592d6e Save skin choice on quit 2015-05-07 18:58:34 +02:00
ac-stef 1f6cd99408 fix CR-handling for looplist 2015-04-18 14:07:45 +02:00
ac-stef f511889731 customisable sort order for file lists in menus 2015-04-12 18:09:36 +02:00
ac-stef 453c79ee6d minor fixes to get master to compile again 2015-04-06 10:37:13 +02:00
ac-stef 5bf27f802c fix memory leak in execdir 2015-03-24 02:06:19 +01:00
ac-stef b4b1c0bf91 add debug warning for unknown argument keywords
"weapon asault" will now print a warning to console.
2015-03-24 02:06:19 +01:00
ac-stef 7b607a6c43 allow comments inside cubescript lists
like this:
  alias listwiththreeelements [
    first   // first element
    second  // second element
    third   // third element
  ]

"echo $listwiththreeelements" will print everything, including comments,
but "echo (listlen $listwiththreeelements)" will print "3", and
"echo (at $listwiththreeelements 1)" will print "second".
2015-03-24 02:06:18 +01:00
ac-stef 5619fb2e7e allow multiple arguments for "pop"
instead of "pop var_a ; pop var_b" you can write "pop var_a var_b"

Also, "pop" will now give back the removed value of the first alias from
the argument list. This allows using the pop'd value one last time.

DOCREF pop
2015-03-06 19:36:29 +01:00
ac-stef 1c402a7d93 omit empty aliases from command completion
Some operations, like pop or looplist, leave empty aliases behind. Mostly,
this is without consequence - but before this commit, they showed up
during command completion.
2015-03-06 14:37:42 +01:00
ac-stef 0f8dbf69aa introduce temporary aliases
An alias, that was at least once used with the new "tempalias" will not be
written to saved.cfg.

So, now there are four ways to create aliases:

1) alias (or "=")
  General alias, who's value gets saved at game exit in saved.cfg, and
  restored at the next restart - unless the alias was created at a time,
  where persistidents was zero (usually during execution of the game's own
  config files during startup).

2) const
  Creates an alias, that can not be changed. Makes it harder for users
  to destroy their config.

3) push
  Reassigns an alias with a new value. After "pop", the old value is
  restored. Allows the use of "local" aliases in scripts. Also avoids
  name conflicts.

4) tempalias
  Like "alias", but the value will not be written to saved.cfg.

The commit also changes aliases, written by the engine itself, to "temp":
gametimestart, __getmaprevisions

DOCREF tempalias
2015-03-06 14:17:08 +01:00
ac-stef 32db3e5e88 new options for saved.cfg
Defaults to omitting variables from saved.cfg, that are still at default
value. By setting omitunchangeddefaults to zero, those variables get
written, but commented out. The variable "groupvariables" sets the number
of variables with similar names, that can be grouped on one line. Setting
it to zero will additionally write min, max and default values and a
short description of the variable to file.

In general, variables, that are still at default value, will not be
restored from saved.cfg, so when the default in the game is changed, all
clients will use that new default. This way, testers don't have to erase
their saved.cfg as often.

DOCREF omitunchangeddefaults groupvariables
2015-03-06 14:01:52 +01:00
ac-stef a013148305 save original aliases instead of local ones
If an alias has a local value assigned (by "push"), this change will write
the original value to saved.cfg instead of the last local value.

This has the additional effect, that aliases, that were created by "push",
will not be written to saved.cfg, since the original value was empty.
2015-03-06 13:46:13 +01:00
ac-stef d9b7e0e159 clean up saved.cfg
* combine all weapon attributes in a table
* sort variables and aliases
* group variables
* implement curname as SVAR
* implement cmdbuf as temporary alias
2015-02-23 20:17:43 +01:00
ac-stef 8153813c14 fix string escaping for SVARs
* avoid double richtext conversion for mspmsg
* fix minor memleak in pushident()
* always escape strings for the command buffer
2015-02-23 20:12:47 +01:00
ac-stef d585550315 automatic escaping for strings
* parsed words starting with " will handle richtext
* all strings in saved.cfg that need escaping are escaped
* new command "escape" to escape a string manually

DOCREF escape
2015-02-23 18:56:32 +01:00
ac-stef 1956f0acc0 clean up loadcrosshair
* use the same list of gun names for all occasions
* switched syntax, so that argument completion will work
* support old syntax, so old config files will work
* fix path handling by disallowing paths altogether ;)

DOCREF loadcrosshair
2015-02-23 18:55:58 +01:00
ac-stef 2231c06528 fix nesting of numargs 2015-02-23 18:52:34 +01:00
ac-stef 71ac04c129 only write variables with non-default values to saved.cfg 2015-02-23 18:52:34 +01:00
ac-stef f75f0c0af4 add optional pre-access function for SVARs
allows a SVAR to be assembled when needed

also:

* mapmsg is now a SVAR
* getmapmsg was removed (now: $mapmsg)
* new editsvar script to edit any SVAR in the console buffer
* nonfunctional menu removed

DOCREF mapmsg getmapmsg editsvar
2015-02-23 18:52:34 +01:00
ac-stef 390c4870ef fix memory leaks in sortlist and swapelements 2015-02-23 18:52:34 +01:00
ac-stef ed3b193b85 fix return value for cubescript command "execute" 2015-02-23 18:52:34 +01:00
ac-stef ec13fd7005 nested alias lookup
best explained with an example:

one = two ; two = three ; three = four
echo $one
> two
echo $$one
> three
echo $$$one
> four
2015-02-23 18:52:34 +01:00
ac-stef 47f71f1288 allow symbolic arguments for some commands
* new command "listoptions" lists the argument options for several
  argument types like entities, weapons and teamnames
* "burstshots", "weapon", "magcontent", "magreserve", "fragmessage" and
  "gibmessage" now allow guns to be specified by name
* "addpunct" allows plaintext arguments like "brackets" and "quotes"
* the "team" command now understands numeric teams
* entity types can now be specified by type index number
* removed some lists from the config files (now provided by listoptions)
* added argument completion for several commands
* change nextprimary from integer to string variable

DOCREF listoptions burstshots weapon addpunct
DOCREF fragmessage gibmessage magcontent magreserve
DOCREF nextprimary
2015-02-23 18:52:04 +01:00
ac-stef e89b2eae86 new looplist command
* optionally works with several variables
* does not leak memory

DOCREF looplist
2015-02-23 18:50:14 +01:00
aurhatandac-stef a284064e9f Complete backwards
Use LSHIFT to direct TAB-completion to browse backwards through the
available alternatives.

also: full cleanup of the commandcomplete()-code [by stef]

* fix crashing buffer overflow
* remove some ancient ludicrous code
* ignore more spaces
* browse command- and filename-alternatives in alphabetical order
* clean up nickcomplete
* more comments (sry)
2015-02-12 12:10:22 +01:00
ac-stef 39cbee947d Merge branch 'master' into next 2015-02-08 16:17:04 +01:00
aurhat fa483e1fcd Add custom description of demos
Custom description is displayed in "Watching demo" and "Play demo" menu.
2014-11-29 16:06:50 +01:00
ac-stef 8604c198e9 cleaning up cubescript hooks
- provide a function to easily assemble and execute the command
- context-selective execution of hooks
- restrict potentially exploitable or harmful hooks to singleplayer-modes
2014-11-12 17:06:35 +01:00
ac-stef 6ede08d011 keep the last five versions of saved.cfg and init.cfg
Renames the existing saved.cfg to saved-old-1.cfg (and an existing -1 to
-2, and so on) before the new saved.cfg is written.

This should help in cases where players mess up their config, because the
config is deleted with a five-game-starts delay.
2014-11-02 23:17:00 +01:00
ac-stef eb60302e67 cleanup
- fix possible crash in conc (but it's still an ugly hack)
- fix noob usage of strcmp
- flag some memory leaks (it would be nice, if the author(s) would clean
   up the mess himself)
- fix crash in substr
- whitespace cleanup

there are plenty more memory leaks in command.cpp - for example, every
goto in cubescript does not clean up anything
2014-05-14 22:54:37 +02:00
ac-stef dcd46bbec9 fix modifyvar
give a proper error message when trying to edit read-only vars
2014-05-14 22:38:29 +02:00
aerkefiende 0819beacdb Fix for command completion, thanks grenadier!
https://sourceforge.net/p/actiongame/bugs/497/#877d

git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7642 e016b1c5-ed68-44aa-a2f7-31cac88cffde
2013-11-09 17:16:59 +00:00
Lucas GAUTHERON dcb847d8ec memory leaks and indent style fix in sortlist/swapelements (thanks SKB)
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7506 e016b1c5-ed68-44aa-a2f7-31cac88cffde
2013-07-20 13:24:50 +00:00
Lucas GAUTHERON 727bb4cb69 autodl: fix downloading for packages containing spaces in their names
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7499 e016b1c5-ed68-44aa-a2f7-31cac88cffde
2013-06-24 12:39:45 +00:00
Lucas GAUTHERON a9d971782b make command.cpp compatible with master
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7418 e016b1c5-ed68-44aa-a2f7-31cac88cffde
2013-03-25 20:46:14 +00:00
Bukz 4100c8ee24 testchar cleanup
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7376 e016b1c5-ed68-44aa-a2f7-31cac88cffde
2013-03-20 22:58:03 +00:00
Lucas GAUTHERON 87782dcca9 warning fixes
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7314 e016b1c5-ed68-44aa-a2f7-31cac88cffde
2013-03-05 20:35:13 +00:00
Lucas GAUTHERON b625928475 allow aliases to be emptied
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7313 e016b1c5-ed68-44aa-a2f7-31cac88cffde
2013-03-05 18:44:45 +00:00
Lucas GAUTHERON 009ed2d8d8 alias/const simplified
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7312 e016b1c5-ed68-44aa-a2f7-31cac88cffde
2013-03-05 18:42:05 +00:00
Bukz 28933e4e8d menu fix/saved.cfg cleanup
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7260 e016b1c5-ed68-44aa-a2f7-31cac88cffde
2013-02-26 23:07:50 +00:00
Alejandro V. Garcia fec6978aed since persistidents is fixed storestring is not needed any more
git-svn-id: svn://svn.code.sf.net/p/actiongame/code/trunk/ac@7215 e016b1c5-ed68-44aa-a2f7-31cac88cffde
2013-02-16 05:07:29 +00:00