Compare commits

..

No commits in common. '0c928a5a3381681b93f117d4189990c2cf22927f' and 'e40883134faa741c298deb4ecc8606015be59a51' have entirely different histories.

  1. 55
      config/FutilityChat.ini
  2. 142
      config/FutilityNicknames.ini
  3. 225
      sources/Commands/ACommandDB.uc
  4. 35
      sources/Commands/ACommandDosh.uc
  5. 415
      sources/Commands/ACommandFeature.uc
  6. 102
      sources/Commands/ACommandFeature_Announcer.uc
  7. 30
      sources/Commands/ACommandGod.uc
  8. 66
      sources/Commands/ACommandInventory.uc
  9. 38
      sources/Commands/ACommandNick.uc
  10. 95
      sources/Commands/ACommandSpawn.uc
  11. 104
      sources/Commands/ACommandTrader.uc
  12. 140
      sources/Commands/ACommandUserData.uc
  13. 80
      sources/Features/FutileChat/FutilityChat.uc
  14. 90
      sources/Features/FutileChat/FutilityChat_Feature.uc
  15. 114
      sources/Features/FutileNickames/FutilityNicknames.uc
  16. 288
      sources/Features/FutileNickames/FutilityNicknames_Feature.uc
  17. 12
      sources/Futility.uc
  18. 6
      sources/Futility_Feature.uc
  19. 26
      sources/Tools/PendingConfigsTool.uc

55
config/FutilityChat.ini

@ -1,34 +1,31 @@
[default FutilityChat]
; This feature allows to configure color of text chat messages.
autoEnable=true
;= How to color text chat messages?
;=
;= 1. `CCS_DoNothing` - do not change color in any way;
;= 2. `CCS_TeamColorForced` - force players' team colors for
;= their messages;
;= 3. `CCS_ConfigColorForced` - force `configuredColor` value for
;= players' messages;
;= 4. `CCS_TeamColorCustom` - use players' team colors for
;= their messages by default, but allow to change color with formatted tags
;= (e.g. "Stop right there, {$crimson criminal} scum!");
;= 5. `CCS_ConfigColorCustom` - use `configuredColor` value for
;= messages by default, but allow to change color with formatted
;= tags (e.g. "Stop right there, {$crimson criminal} scum!");
;=
;= Default is `CCS_DoNothing`, corresponding to vanilla behaviour.
; How to color text chat messages?
; 1. `CCS_DoNothing` - do not change color in any way;
; 2. `CCS_TeamColorForced` - force players' team colors for
; their messages;
; 3. `CCS_ConfigColorForced` - force `configuredColor` value for
; players' messages;
; 4. `CCS_TeamColorCustom` - use players' team colors for
; their messages by default, but allow to change color with formatted
; tags (e.g. "Stop right there, {$crimson criminal} scum!");
; 5. `CCS_ConfigColorCustom` - use `configuredColor` value for
; messages by default, but allow to change color with formatted
; tags (e.g. "Stop right there, {$crimson criminal} scum!");
; Default is `CCS_DoNothing`, corresponding to vanilla behaviour.
colorSetting=CCS_DoNothing
;= Color that will be used if either of `CCS_ConfigColorForced` or
;= `CCS_ConfigColorCustom` options were used in `colorSetting`.
;= Default value is white: (R=255,G=255,B=255,A=255), has no vanilla
;= equivalent.
; Color that will be used if either of `CCS_ConfigColorForced` or
; `CCS_ConfigColorCustom` options were used in `colorSetting`.
; Default value is white: (R=255,G=255,B=255,A=255),
; has no vanilla equivalent.
configuredColor=(R=255,G=255,B=255,A=255)
;= Allows to modify team color's value for the chat messages
;= (if either of `CCS_TeamColorForced` or `CCS_TeamColorCustom` options
;= were used) to be lighter or darker.
;= This value is clamped between -1 and 1:
;=
;= * `0` means using the same color;
;= * range (0; 1) - gives you lighter colors (`1` being white);
;= * range (-1; 0) - gives you darker colors (`-1` being black);
;=
;= Default value is `0.6`, has no vanilla equivalent.
; Allows to modify team color's value for the chat messages
; (if either of `CCS_TeamColorForced` or `CCS_TeamColorCustom` options
; were used) to be lighter or darker.
; This value is clamped between -1 and 1.
; * `0` means using the same color;
; * range (0; 1) - gives you lighter colors (`1` being white);
; * range (-1; 0) - gives you darker colors (`-1` being black);
; Default value is `0.6`, has no vanilla equivalent.
teamColorModifier=0.6

142
config/FutilityNicknames.ini

@ -1,67 +1,64 @@
[default FutilityNicknames]
;= This feature allows to configure nickname limitations for the server.
;= It allows you to customize vanilla limitations for nickname length and
;= color with those of your own design. Enabling this feature overwrites
;= default behaviour.
; This feature allows to configure nickname limitations for the server.
; It allows you to customize vanilla limitations for nickname length and
; color with those of your own design. Enabling this feature overwrites
; default behaviour.
autoEnable=true
;= How to treat whitespace characters inside players' nicknames.
;=
;= * `NSA_DoNothing` - does nothing, leaving whitespaces as they are;=
;= * `NSA_Trim` - removes leading and trailing whitespaces for nicknames;=
;= * `NSA_Simplify` - removes leading and trailing whitespaces
;= for nicknames, also reducing a sequence of whitespaces inside
;= nickname to a single space, e.g. "my nick" becomes "my nick".
;=
;= Default is `NSA_DoNothing`, same as on vanilla.
; How to treat whitespace characters inside players' nicknames.
; * `NSA_DoNothing` - does nothing, leaving whitespaces as they are;
; * `NSA_Trim` - removes leading and trailing whitespaces for nicknames;
; * `NSA_Simplify` - removes leading and trailing whitespaces
; for nicknames, also reducing a sequence of whitespaces inside
; nickname to a single space, e.g. "my nick" becomes "my nick".
; Default is `NSA_DoNothing`, same as on vanilla.
spacesAction=NSA_DoNothing
;= How to treat colored nicknames.
;= * `NCP_ForbidColor` - completely strips down any color from nicknames;=
;= * `NCP_ForceTeamColor` - forces all nicknames to have player's current
;= team's color;=
;= * `NCP_ForceSingleColor` - allows nickname to be painted with a single
;= color (sets nickname's color to that of the first character);=
;= * `NCP_AllowAnyColor` - allows nickname to be colored in any way player
;= wants.
;= Default is `NCP_ForbidColor`, same as on vanilla.
; How to treat colored nicknames.
; * `NCP_ForbidColor` - completely strips down any color from nicknames;
; * `NCP_ForceTeamColor` - forces all nicknames to have player's current
; team's color;
; * `NCP_ForceSingleColor` - allows nickname to be painted with a single
; color (sets nickname's color to that of the first character);
; * `NCP_AllowAnyColor` - allows nickname to be colored in any way player
; wants.
; Default is `NCP_ForbidColor`, same as on vanilla.
colorPermissions=NCP_ForbidColor
;= Set this to `true` if you wish to replace all whitespace characters with
;= underscores and `false` to leave them as is.
;= Default is `true`, same as on vanilla. However there is one difference:
;= Futility replaces all whitespace characters (including tabulations,
;= non-breaking spaces, etc.) instead of only ' '.
; Set this to `true` if you wish to replace all whitespace characters with
; underscores and `false` to leave them as is.
; Default is `true`, same as on vanilla. However there is one difference:
; Futility replaces all whitespace characters (including tabulations,
; non-breaking spaces, etc.) instead of only ' '.
replaceSpacesWithUnderscores=true
;= Set this to `true` to remove single 'quotation marks' and `false` to
;= leave them. Default is `false`, same as on vanilla.
; Set this to `true` to remove single 'quotation marks' and `false` to
; leave them. Default is `false`, same as on vanilla.
removeSingleQuotationMarks=false
;= Set this to `true` to remove dobule 'quotation marks' and `false` to
;= leave them. Default is `true`, same as on vanilla.
; Set this to `true` to remove dobule 'quotation marks' and `false` to
; leave them. Default is `true`, same as on vanilla.
removeDoubleQuotationMarks=true
;= Max allowed nickname length. Negative values disable any length limits.
;=
;= NOTE #1: `0` resets all nicknames to be empty and,
;= if `correctEmptyNicknames` is set to `true`, they will be replaced with
;= one of the fallback nicknames
;= (see `correctEmptyNicknames` and `fallbackNickname`).
;=
;= NOTE #2: Because of how color swapping in vanilla Killing Floor works,
;= every color swap makes text count as being about 4 characters longer.
;= So if one uses too many colors in the nickname, for drawing functions
;= it will appear to be longer than it actually is and it *will* mess up
;= UI. Unless you are using custom HUD it is recommended to keep this value
;= at default `20` and forbid colored nicknames
;= (by setting `colorPermissions=NCP_ForbidColor`). Or to allow only one
;= color (by setting `colorPermissions=NCP_ForceSingleColor` or
;= `colorPermissions=NCP_ForceTeamColor`) and reducing `maxNicknameLength`
;= to `16` (20 characters - 4 for color swap).
;= If you want to increase the limit above that, you can also do your
;= own research by testing nicknames of various length on
;= screen resolutions you care about.
; Max allowed nickname length. Negative values disable any length limits.
;
; NOTE #1: `0` resets all nicknames to be empty and,
; if `correctEmptyNicknames` is set to `true`, they will be replaced with
; one of the fallback nicknames
; (see `correctEmptyNicknames` and `fallbackNickname`).
; NOTE #2: Because of how color swapping in vanilla Killing Floor works,
; every color swap makes text count as being about 4 characters longer.
; So if one uses too many colors in the nickname, for drawing functions
; it will appear to be longer than it actually is and it *will* mess up
; UI. Unless you are using custom HUD it is recommended to keep this value
; at default `20` and forbid colored nicknames
; (by setting `colorPermissions=NCP_ForbidColor`). Or to allow only one
; color (by setting `colorPermissions=NCP_ForceSingleColor` or
; `colorPermissions=NCP_ForceTeamColor`) and reducing `maxNicknameLength`
; to `16` (20 characters - 4 for color swap).
; If you want to increase the limit above that, you can also do your
; own research by testing nicknames of various length on
; screen resolutions you care about.
maxNicknameLength=20
;= Should we replace empty player nicknames with a random fallback nickname
;= (defined in `fallbackNickname` array)?
; Should we replace empty player nicknames with a random fallback nickname
; (defined in `fallbackNickname` array)?
correctEmptyNicknames=true
;= Array of fallback nicknames that will be used to replace any empty nicknames
;= if `correctEmptyNicknames` is set to `true`.
; Array of fallback nicknames that will be used to replace any empty nicknames
; if `correctEmptyNicknames` is set to `true`.
fallbackNickname="Fresh Meat"
fallbackNickname="Rotten Meat"
fallbackNickname="Troll Meat"
@ -73,21 +70,20 @@ fallbackNickname="Boar Meat"
fallbackNickname="Walrus Meat"
fallbackNickname="Bug Meat"
fallbackNickname="Horse Meat"
;= Guaranteed order of applying changes (only chosen ones) is as following:
;= 1. Trim/simplify spaces;=
;= 2. Remove single and double quotation marks;=
;= 3. Enforce max limit of nickname's length;=
;= 4. Replace empty nickname with fallback nickname (no further changes
;= will be applied to fallback nickname in that case);=
;= 5. Enforce color limitation;=
;= 6. Replace remaining whitespaces with underscores.
;=
;= NOTE #1: as follows from the instruction described above, no changes will
;= ever be applied to fallback nicknames (unless player's nickname
;= coincides with one by pure accident).
;=
;= NOTE #2: whitespaces inside steam nicknames are converted into underscores
;= before they are passed into the game and this is a change Futility
;= cannot currently abort.
;= Therefore all changes relevant to whitespaces inside nicknames will only
;= be applied to in-game changes.
; Guaranteed order of applying changes (only chosen ones) is as following:
; 1. Trim/simplify spaces;
; 2. Remove single and double quotation marks;
; 3. Enforce max limit of nickname's length;
; 4. Replace empty nickname with fallback nickname (no further changes
; will be applied to fallback nickname in that case);
; 5. Enforce color limitation;
; 6. Replace remaining whitespaces with underscores.
;
; NOTE #1: as follows from the instruction described above, no changes will
; ever be applied to fallback nicknames (unless player's nickname
; coincides with one by pure accident).
; NOTE #2: whitespaces inside steam nicknames are converted into underscores
; before they are passed into the game and this is a change Futility
; cannot currently abort.
; Therefore all changes relevant to whitespaces inside nicknames will only
; be applied to in-game changes.

225
sources/Commands/ACommandDB.uc

@ -1,6 +1,6 @@
/**
* Command for working with databases.
* Copyright 2021-2023 Anton Tarasenko
* Copyright 2021-2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
@ -65,63 +65,87 @@ struct DBPointerPair
};
var protected const int TCREATE, TDELETE, TLIST, TREAD, TSIZE, TKEYS, TREMOVE;
var protected const int TWRITE, TINCREMENT, TDATABASE_NAME, TDATABASE_LINK;
var protected const int TJSON_VALUE, TQUERY_INVALID_POINTER, TQUERY_INVALID_DB;
var protected const int TWRITE, TWRITE_ARRAY, TWRITE_NULL, TWRITE_BOOLEAN;
var protected const int TWRITE_INTEGER, TWRITE_FLOAT, TWRITE_STRING, TINCREMENT;
var protected const int TDATABASE_NAME, TDATABASE_LINK, TJSON_VALUE;
var protected const int TOBJECT_KEYS_ARE, TOBJECT_SIZE_IS, TQUERY_COMPLETED;
var protected const int TQUERY_INVALID_POINTER, TQUERY_INVALID_DB;
var protected const int TQUERY_INVALID_DATA, TAVAILABLE_DATABASES, TDA_DELETED;
var protected const int TDB_DOESNT_EXIST, TDB_ALREADY_EXISTS, TDB_CREATED;
var protected const int TDB_CANNOT_BE_CREATED, TNO_DEFAULT_COMMAND, TBAD_DBLINK;
protected function BuildData(CommandDataBuilder builder)
{
builder.Group(P("admin"));
builder.Summary(P("Read and edit data in your databases."
builder.Name(P("db")).Group(P("admin"))
.Summary(P("Read and edit data in your databases."
@ "Databases' values are addressed with links:"
@ "\"<db_name>:<json_path>\""));
builder.SubCommand(T(TCREATE));
builder.ParamText(T(TDATABASE_NAME));
builder.Describe(P("Creates new database with a specified name."));
builder.SubCommand(T(TDELETE));
builder.ParamText(T(TDATABASE_NAME));
builder.Describe(P("Completely deletes specified database."));
builder.SubCommand(T(TLIST));
builder.Describe(P("Lists available databases."));
builder.SubCommand(T(TREAD));
builder.ParamText(T(TDATABASE_LINK));
builder.Describe(P("Reads data from location given by the `databaseLink`."));
builder.SubCommand(T(TSIZE));
builder.ParamText(T(TDATABASE_LINK));
builder.Describe(P("Gets amount of elements inside JSON array or object at"
builder.SubCommand(T(TCREATE))
.ParamText(T(TDATABASE_NAME))
.Describe(P("Creates new database with a specified name."));
builder.SubCommand(T(TDELETE))
.ParamText(T(TDATABASE_NAME))
.Describe(P("Completely deletes specified database."));
builder.SubCommand(T(TLIST))
.Describe(P("Lists available databases."));
builder.SubCommand(T(TREAD))
.ParamText(T(TDATABASE_LINK))
.Describe(P("Reads data from location given by the `databaseLink`."));
builder.SubCommand(T(TSIZE))
.ParamText(T(TDATABASE_LINK))
.Describe(P("Gets amount of elements inside JSON array or object at"
@ "location given by the `databaseLink`."));
builder.SubCommand(T(TKEYS));
builder.ParamText(T(TDATABASE_LINK));
builder.Describe(P("Lists keys of JSON object at location given by"
builder.SubCommand(T(TKEYS))
.ParamText(T(TDATABASE_LINK))
.Describe(P("Lists keys of JSON object at location given by"
@ "the `databaseLink`."));
builder.SubCommand(T(TREMOVE));
builder.ParamText(T(TDATABASE_LINK));
builder.Describe(P("Removes data from location given by the `databaseLink`."));
builder.SubCommand(T(TWRITE));
builder.ParamText(T(TDATABASE_LINK));
builder.ParamJSON(T(TJSON_VALUE));
builder.Describe(P("Writes specified JSON value into location given by"
builder.SubCommand(T(TREMOVE))
.ParamText(T(TDATABASE_LINK))
.Describe(P("Removes data from location given by the `databaseLink`."));
builder.SubCommand(T(TWRITE))
.ParamText(T(TDATABASE_LINK))
.ParamObject(T(TJSON_VALUE))
.Describe(P("Writes specified JSON object into location given by"
@ "the `databaseLink`."));
builder.Option(T(TINCREMENT));
builder.Describe(F("Specifying this option for any of the"
builder.SubCommand(T(TWRITE_ARRAY))
.ParamText(T(TDATABASE_LINK))
.ParamArray(T(TJSON_VALUE))
.Describe(P("Writes specified JSON array into location given by"
@ "the `databaseLink`."));
builder.SubCommand(T(TWRITE_NULL))
.ParamText(T(TDATABASE_LINK))
.Describe(P("Writes specified null value into location given by"
@ "the `databaseLink`."));
builder.SubCommand(T(TWRITE_BOOLEAN))
.ParamText(T(TDATABASE_LINK))
.ParamBoolean(T(TJSON_VALUE))
.Describe(P("Writes specified JSON boolean into location given by"
@ "the `databaseLink`."));
builder.SubCommand(T(TWRITE_INTEGER))
.ParamText(T(TDATABASE_LINK))
.ParamInteger(T(TJSON_VALUE))
.Describe(P("Writes specified integer as JSON number into location"
@ "given by the `databaseLink`."));
builder.SubCommand(T(TWRITE_FLOAT))
.ParamText(T(TDATABASE_LINK))
.ParamNumber(T(TJSON_VALUE))
.Describe(P("Writes specified float as JSON number into location"
@ "given by the `databaseLink`."));
builder.SubCommand(T(TWRITE_STRING))
.ParamText(T(TDATABASE_LINK))
.ParamText(T(TJSON_VALUE))
.Describe(P("Writes specified JSON string into location given by"
@ "the `databaseLink`."));
builder.Option(T(TINCREMENT))
.Describe(F("Specifying this option for any of the"
@ "{$TextEmphasis 'write'} subcommands will cause them to append"
@ "data to the old one, instead of rewriting it."));
}
protected function PushPlayer(EPlayer nextPlayer, Database callDatabase)
{
local EPlayer playerCopy;
if (nextPlayer != none) {
playerCopy = EPlayer(nextPlayer.Copy());
}
if (callDatabase != none) {
callDatabase.NewRef();
}
queueWaitingListPlayers[queueWaitingListPlayers.length] = playerCopy;
queueWaitingListPlayers[queueWaitingListPlayers.length] =
EPlayer(nextPlayer.Copy());
queueWaitingListDatabases[queueWaitingListDatabases.length] = callDatabase;
}
@ -135,10 +159,9 @@ protected function EPlayer PopPlayer(Database relevantDatabase)
while (i < queueWaitingListDatabases.length)
{
if (queueWaitingListDatabases[i].IsEqual(relevantDatabase))
if (queueWaitingListDatabases[i] != relevantDatabase)
{
result = queueWaitingListPlayers[i];
queueWaitingListDatabases[i].FreeSelf();
queueWaitingListPlayers.Remove(i, 1);
queueWaitingListDatabases.Remove(i, 1);
break;
@ -152,11 +175,8 @@ protected function EPlayer PopPlayer(Database relevantDatabase)
return none;
}
protected function Executed(
CallData arguments,
EPlayer instigator,
CommandPermissions permissions
) {
protected function Executed(CallData arguments, EPlayer instigator)
{
local AcediaObject valueToWrite;
local DBPointerPair pair;
local Text subCommand;
@ -176,7 +196,7 @@ protected function Executed(
}
// Remember the last player we are making a query to and make that query
PushPlayer(instigator, pair.database);
if (subCommand.Compare(T(TWRITE)))
if (subCommand.StartsWith(T(TWRITE)))
{
valueToWrite = arguments.parameters.GetItem(T(TJSON_VALUE));
if (arguments.options.HasKey(T(TINCREMENT)))
@ -246,11 +266,11 @@ private function DBPointerPair TryLoadingDB(BaseText databaseLink)
if (databaseLink == none) {
return result;
}
result.database = _server.db.Load(databaseLink);
result.database = _.db.Load(databaseLink);
if (result.database == none) {
return result;
}
result.pointer = _server.db.GetPointer(databaseLink);
result.pointer = _.db.GetPointer(databaseLink);
return result;
}
@ -259,12 +279,12 @@ protected function CreateDatabase(EPlayer instigator, Text databaseName)
if (instigator == none) {
return;
}
if (_server.db.ExistsLocal(databaseName))
if (_.db.ExistsLocal(databaseName))
{
callerConsole.WriteLine(T(TDB_ALREADY_EXISTS));
return;
}
if (_server.db.NewLocal(databaseName) != none) {
if (_.db.NewLocal(databaseName) != none) {
callerConsole.WriteLine(T(TDB_CREATED));
}
else {
@ -277,7 +297,7 @@ protected function DeleteDatabase(EPlayer instigator, Text databaseName)
if (instigator == none) {
return;
}
if (_server.db.DeleteLocal(databaseName)) {
if (_.db.DeleteLocal(databaseName)) {
callerConsole.WriteLine(T(TDA_DELETED));
}
else {
@ -294,7 +314,7 @@ protected function ListDatabases(EPlayer instigator)
if (instigator == none) {
return;
}
availableDatabases = _server.db.ListLocal();
availableDatabases = _.db.ListLocal();
console = callerConsole;
console.Write(T(TAVAILABLE_DATABASES));
for (i = 0; i < availableDatabases.length; i += 1)
@ -332,8 +352,7 @@ protected function OutputStatus(
protected function DisplayData(
Database.DBQueryResult result,
AcediaObject data,
Database source,
int requestID)
Database source)
{
local Text printedJSON;
local EPlayer instigator;
@ -354,8 +373,7 @@ protected function DisplayData(
protected function DisplaySize(
Database.DBQueryResult result,
int size,
Database source,
int requestID)
Database source)
{
local Text sizeAsText;
local EPlayer instigator;
@ -378,8 +396,7 @@ protected function DisplaySize(
protected function DisplayKeys(
Database.DBQueryResult result,
ArrayList keys,
Database source,
int requestID)
Database source)
{
local int i;
local Text nextKey;
@ -413,8 +430,7 @@ protected function DisplayKeys(
protected function DisplayResponse(
Database.DBQueryResult result,
Database source,
int requestID)
Database source)
{
local EPlayer instigator;
@ -425,7 +441,6 @@ protected function DisplayResponse(
defaultproperties
{
preferredName = "db"
TCREATE = 0
stringConstants(0) = "create"
TDELETE = 1
@ -442,40 +457,52 @@ defaultproperties
stringConstants(6) = "remove"
TWRITE = 7
stringConstants(7) = "write"
TINCREMENT = 8
stringConstants(8) = "increment"
TDATABASE_NAME = 9
stringConstants(9) = "databaseName"
TDATABASE_LINK = 10
stringConstants(10) = "databaseLink"
TJSON_VALUE = 11
stringConstants(11) = "jsonValue"
TOBJECT_KEYS_ARE = 12
stringConstants(12) = "{$TextEmphasis Object keys are:} "
TOBJECT_SIZE_IS = 13
stringConstants(13) = "{$TextEmphasis Object size is:} "
TQUERY_COMPLETED = 14
stringConstants(14) = "{$TextPositive Database query was completed!}"
TQUERY_INVALID_POINTER = 15
stringConstants(15) = "{$TextFailure Query was provided with an invalid JSON pointer.}"
TQUERY_INVALID_DB = 16
stringConstants(16) = "{$TextFailure Operation could not finish because database is damaged and unusable.}"
TQUERY_INVALID_DATA = 17
stringConstants(17) = "{$TextFailure Query data is invalid.}"
TAVAILABLE_DATABASES = 18
stringConstants(18) = "{$TextEmphasis Available databases:} "
TDA_DELETED = 19
stringConstants(19) = "{$TextPositive Database was deleted.}"
TDB_DOESNT_EXIST = 20
stringConstants(20) = "{$TextFailure Database with specified name does not exist.}"
TDB_ALREADY_EXISTS = 21
stringConstants(21) = "{$TextFailure Database with specified name already exists.}"
TDB_CREATED = 22
stringConstants(22) = "{$TextPositive Database was created.}"
TDB_CANNOT_BE_CREATED = 23
stringConstants(23) = "{$TextFailure Database cannot be created.}"
TNO_DEFAULT_COMMAND = 24
stringConstants(24) = "{$TextFailure Default command does nothing. Use on of the sub-commands.}"
TBAD_DBLINK = 25
stringConstants(25) = "{$TextFailure Database could not be read for the specified link.}"
TWRITE_ARRAY = 8
stringConstants(8) = "write_array"
TWRITE_NULL = 9
stringConstants(9) = "write_null"
TWRITE_BOOLEAN = 10
stringConstants(10) = "write_boolean"
TWRITE_INTEGER = 11
stringConstants(11) = "write_integer"
TWRITE_FLOAT = 12
stringConstants(12) = "write_float"
TWRITE_STRING = 13
stringConstants(13) = "write_string"
TINCREMENT = 14
stringConstants(14) = "increment"
TDATABASE_NAME = 15
stringConstants(15) = "databaseName"
TDATABASE_LINK = 16
stringConstants(16) = "databaseLink"
TJSON_VALUE = 17
stringConstants(17) = "jsonValue"
TOBJECT_KEYS_ARE = 18
stringConstants(18) = "{$TextEmphasis Object keys are:} "
TOBJECT_SIZE_IS = 19
stringConstants(19) = "{$TextEmphasis Object size is:} "
TQUERY_COMPLETED = 20
stringConstants(20) = "{$TextPositive Database query was completed!}"
TQUERY_INVALID_POINTER = 21
stringConstants(21) = "{$TextNegative Query was provided with an invalid JSON pointer.}"
TQUERY_INVALID_DB = 22
stringConstants(22) = "{$TextNegative Operation could not finish because database is damaged and unusable.}"
TQUERY_INVALID_DATA = 23
stringConstants(23) = "{$TextNegative Query data is invalid.}"
TAVAILABLE_DATABASES = 24
stringConstants(24) = "{$TextEmphasis Available databases:} "
TDA_DELETED = 25
stringConstants(25) = "{$TextPositive Database was deleted.}"
TDB_DOESNT_EXIST = 26
stringConstants(26) = "{$TextNegative Database with specified name does not exist.}"
TDB_ALREADY_EXISTS = 27
stringConstants(27) = "{$TextNegative Database with specified name already exists.}"
TDB_CREATED = 28
stringConstants(28) = "{$TextPositive Database was created.}"
TDB_CANNOT_BE_CREATED = 29
stringConstants(29) = "{$TextNegative Database cannot be created.}"
TNO_DEFAULT_COMMAND = 30
stringConstants(30) = "{$TextNegative Default command does nothing. Use on of the sub-commands.}"
TBAD_DBLINK = 31
stringConstants(31) = "{$TextNegative Database could not be read for the specified link.}"
}

35
sources/Commands/ACommandDosh.uc

@ -29,23 +29,23 @@ protected function Finalizer()
protected function BuildData(CommandDataBuilder builder)
{
builder.Group(P("gameplay"));
builder.Summary(P("Changes amount of money."));
builder.Name(P("dosh")).Group(P("gameplay"))
.Summary(P("Changes amount of money."));
builder.RequireTarget();
builder.ParamInteger(P("amount"));
builder.Describe(P("Gives (or takes if negative) players a specified <amount>"
builder.ParamInteger(P("amount"))
.Describe(P("Gives (or takes if negative) players a specified <amount>"
@ "of money."));
builder.SubCommand(P("set"));
builder.ParamInteger(P("amount"));
builder.Describe(P("Sets player's money to a specified <amount>."));
builder.Option(P("min"));
builder.ParamInteger(P("minValue"));
builder.Describe(F("Players will retain at least this amount of dosh after"
builder.SubCommand(P("set"))
.ParamInteger(P("amount"))
.Describe(P("Sets player's money to a specified <amount>."));
builder.Option(P("min"))
.ParamInteger(P("minValue"))
.Describe(F("Players will retain at least this amount of dosh after"
@ "the command's execution. In case of conflict, overrides"
@ "'{$TextEmphasis --max}' option. `0` is assumed by default."));
builder.Option(P("max"), P("M"));
builder.ParamInteger(P("maxValue"));
builder.Describe(F("Players will have at most this amount of dosh after"
builder.Option(P("max"), P("M"))
.ParamInteger(P("maxValue"))
.Describe(F("Players will have at most this amount of dosh after"
@ "the command's execution. In case of conflict, it is overridden"
@ "by '{$TextEmphasis --min}' option."));
announcer = ACommandDosh_Announcer(
@ -55,9 +55,8 @@ protected function BuildData(CommandDataBuilder builder)
protected function ExecutedFor(
EPlayer target,
CallData arguments,
EPlayer instigator,
CommandPermissions permissions
) {
EPlayer instigator)
{
local int oldAmount, newAmount;
local int amount, minValue, maxValue;
@ -89,6 +88,6 @@ protected function ExecutedFor(
}
}
defaultproperties {
preferredName = "dosh"
defaultproperties
{
}

415
sources/Commands/ACommandFeature.uc

@ -21,87 +21,87 @@ class ACommandFeature extends Command
dependson(PendingConfigsTool);
var private class<Feature> selectedFeatureClass;
var private Text selectedFeatureName;
var private Text selectedConfigName;
var private PendingConfigsTool pendingConfigs;
var private ACommandFeature_Announcer announcer;
protected function Constructor() {
pendingConfigs = PendingConfigsTool(_.memory.Allocate(class'PendingConfigsTool'));
protected function Constructor()
{
pendingConfigs =
PendingConfigsTool(_.memory.Allocate(class'PendingConfigsTool'));
super.Constructor();
}
protected function Finalizer() {
protected function Finalizer()
{
_.memory.Free(announcer);
_.memory.Free(pendingConfigs);
super.Finalizer();
}
protected function BuildData(CommandDataBuilder builder) {
builder.Group(P("admin"));
builder.Summary(P("Managing features."));
builder.Describe(P("Command for managing features and their configs."));
builder.SubCommand(P("enable"));
builder.ParamText(P("feature"),, P("feature"));
builder.OptionalParams();
builder.ParamText(P("config"));
builder.Describe(P("Enables specified <feature>. If <config> isn't specified -"
protected function BuildData(CommandDataBuilder builder)
{
builder.Name(P("feature")).Group(P("admin"))
.Summary(P("Managing features."))
.Describe(P("Command for managing features and their configs."));
builder.SubCommand(P("enable"))
.ParamText(P("feature"))
.OptionalParams()
.ParamText(P("config"))
.Describe(P("Enables specified <feature>. If <config> isn't specified -"
@ "choses the \"default\" one, making new config with default"
@ "settings if it doesn't exist."));
builder.SubCommand(P("disable"));
builder.ParamText(P("feature"),, P("feature"));
builder.Describe(P("Disables specified <feature>."));
builder.SubCommand(P("showconf"));
builder.ParamText(P("feature"),, P("feature"));
builder.OptionalParams();
builder.ParamText(P("config"));
builder.Describe(P("Show given <config> for the given <feature>."));
builder.SubCommand(P("editconf"));
builder.ParamText(P("feature"),, P("feature"));
builder.ParamText(P("config"));
builder.ParamText(P("variable_path"));
builder.ParamJSON(P("value"));
builder.Describe(P("Changes a value inside given <config> of the given"
builder.SubCommand(P("disable"))
.ParamText(P("feature"))
.Describe(P("Disables specified <feature>."));
builder.SubCommand(P("showconf"))
.ParamText(P("feature"))
.OptionalParams()
.ParamText(P("config"))
.Describe(P("Show given <config> for the given <feature>."));
builder.SubCommand(P("editconf"))
.ParamText(P("feature"))
.ParamText(P("config"))
.ParamText(P("variable_path"))
.ParamRemainder(P("value"))
.Describe(P("Changes a value inside given <config> of the given"
@ "<feature> by setting value at JSON path <variable_path> to"
@ "the JSON value <value>. Changes won't be immediately applied to"
@ "the game and kept as pending."));
builder.SubCommand(P("saveconf"));
builder.ParamText(P("feature"),, P("feature"));
builder.ParamText(P("config"));
builder.Describe(P("Saves pending changes for the given <config> of the given"
builder.SubCommand(P("saveconf"))
.ParamText(P("feature"))
.ParamText(P("config"))
.Describe(P("Saves pending changes for the given <config> of the given"
@ "<feature>."));
builder.SubCommand(P("newconf"));
builder.ParamText(P("feature"),, P("feature"));
builder.ParamText(P("config"));
builder.Describe(P("Creates new config for the given <feature>."));
builder.SubCommand(P("removeconf"));
builder.ParamText(P("feature"),, P("feature"));
builder.ParamText(P("config"));
builder.Describe(P("Removes specified <config> of the specified <feature>."));
builder.SubCommand(P("autoconf"));
builder.ParamText(P("feature"),, P("feature"));
builder.OptionalParams();
builder.ParamText(P("config"));
builder.Describe(P("Changes current auto config config of the specified"
builder.SubCommand(P("newconf"))
.ParamText(P("feature"))
.ParamText(P("config"))
.Describe(P("Creates new config for the given <feature>."));
builder.SubCommand(P("removeconf"))
.ParamText(P("feature"))
.ParamText(P("config"))
.Describe(P("Removes specified <config> of the specified <feature>."));
builder.SubCommand(P("autoconf"))
.ParamText(P("feature"))
.OptionalParams()
.ParamText(P("config"))
.Describe(P("Changes current auto config config of the specified"
@ "<feature>. Auto config is a config that is supposed to be"
@ "automatically enabled at the start of the Acedia, unless"
@ "otherwise specified for the loader."));
builder.Option(P("all"));
builder.Describe(F("Affects subcommand {$TextEmphasis showconf} by making it"
builder.Option(P("all"))
.Describe(F("Affects subcommand {$TextEmphasis showconf} by making it"
@ "show all available configs."));
builder.Option(P("save"));
builder.Describe(F("Affects subcommand {$TextEmphasis editconf} by making it"
builder.Option(P("save"))
.Describe(F("Affects subcommand {$TextEmphasis editconf} by making it"
@ "also save all pending changes."));
announcer = ACommandFeature_Announcer(
_.memory.Allocate(class'ACommandFeature_Announcer'));
}
protected function Executed(
CallData arguments,
EPlayer instigator,
CommandPermissions permissions
) {
protected function Executed(CallData arguments, EPlayer instigator)
{
local bool saveFlag, allFlag;
announcer.Setup(none, instigator, othersConsole);
@ -110,52 +110,60 @@ protected function Executed(
SelectFeatureAndConfig(arguments);
if (arguments.subCommandName.IsEmpty()) {
ShowAllFeatures();
} else if (arguments.subCommandName.Compare(P("enable"))) {
}
else if (arguments.subCommandName.Compare(P("enable"))) {
EnableFeature();
} else if (arguments.subCommandName.Compare(P("disable"))) {
}
else if (arguments.subCommandName.Compare(P("disable"))) {
DisableFeature();
} else if (arguments.subCommandName.Compare(P("showconf"))) {
}
else if (arguments.subCommandName.Compare(P("showconf"))) {
ShowSelectedConfigs(allFlag);
} else if (arguments.subCommandName.Compare(P("editconf"))) {
}
else if (arguments.subCommandName.Compare(P("editconf")))
{
EditFeatureConfig(
arguments.parameters.GetText(P("variable_path")),
arguments.parameters.GetItem(P("value")),
arguments.parameters.GetText(P("value")),
saveFlag);
} else if (arguments.subCommandName.Compare(P("saveconf"))) {
}
else if (arguments.subCommandName.Compare(P("saveconf"))) {
SaveFeatureConfig();
} else if (arguments.subCommandName.Compare(P("newconf"))) {
}
else if (arguments.subCommandName.Compare(P("newconf"))) {
NewFeatureConfig();
} else if (arguments.subCommandName.Compare(P("removeconf"))) {
}
else if (arguments.subCommandName.Compare(P("removeconf"))) {
RemoveFeatureConfig();
} else if (arguments.subCommandName.Compare(P("autoconf"))) {
}
else if (arguments.subCommandName.Compare(P("autoconf"))) {
SetAutoFeatureConfig();
}
_.memory.Free2(selectedConfigName, selectedFeatureName);
_.memory.Free(selectedConfigName);
selectedConfigName = none;
selectedFeatureName = none;
}
protected function SelectFeatureAndConfig(CallData arguments) {
local Text featureClassName, userGivenConfigName;
protected function SelectFeatureAndConfig(CallData arguments)
{
local Text userGivenFeatureName, userGivenConfigName;
selectedFeatureName = arguments.parameters.GetTextBy(P("/feature/alias"));
featureClassName = arguments.parameters.GetTextBy(P("/feature/value"));
selectedFeatureClass = LoadFeatureClass(featureClassName);
userGivenFeatureName = arguments.parameters.GetText(P("feature"));
selectedFeatureClass = LoadFeatureClass(userGivenFeatureName);
if (selectedFeatureClass == none && !arguments.subCommandName.IsEmpty()) {
_.memory.Free(selectedFeatureName);
selectedFeatureName = none;
return;
}
_.memory.Free(featureClassName);
_.memory.Free(userGivenFeatureName);
userGivenConfigName = arguments.parameters.GetText(P("config"));
if (userGivenConfigName != none) {
if (userGivenConfigName != none)
{
selectedConfigName = userGivenConfigName.LowerCopy();
userGivenConfigName.FreeSelf();
}
pendingConfigs.SelectConfig(selectedFeatureClass, selectedConfigName);
}
protected function EnableFeature() {
protected function EnableFeature()
{
local bool wasEnabled;
local Text oldConfig, newConfig;
local Feature instance;
@ -164,50 +172,59 @@ protected function EnableFeature() {
oldConfig = selectedFeatureClass.static.GetCurrentConfig();
newConfig = PickConfigBasedOnParameter();
// Already enabled with the same config!
if (oldConfig != none && oldConfig.Compare(newConfig, SCASE_INSENSITIVE)) {
announcer.AnnounceFailedAlreadyEnabled(selectedFeatureName, newConfig);
if (oldConfig != none && oldConfig.Compare(newConfig, SCASE_INSENSITIVE))
{
announcer.AnnounceFailedAlreadyEnabled(selectedFeatureClass, newConfig);
_.memory.Free(newConfig);
_.memory.Free(oldConfig);
return;
}
// Try enabling and report the result
instance = selectedFeatureClass.static.EnableMe(newConfig);
if (instance == none) {
if (instance == none)
{
announcer.AnnounceFailedCannotEnableFeature(
selectedFeatureName,
selectedFeatureClass,
newConfig);
} else if (wasEnabled) {
}
else if (wasEnabled)
{
announcer.AnnounceSwappedConfig(
selectedFeatureName,
selectedFeatureClass,
oldConfig,
newConfig);
} else {
announcer.AnnounceEnabledFeature(selectedFeatureName, newConfig);
}
else {
announcer.AnnounceEnabledFeature(selectedFeatureClass, newConfig);
}
_.memory.Free(newConfig);
_.memory.Free(oldConfig);
}
protected function DisableFeature() {
if (!selectedFeatureClass.static.IsEnabled()) {
announcer.AnnounceFailedAlreadyDisabled(selectedFeatureName);
protected function DisableFeature()
{
if (!selectedFeatureClass.static.IsEnabled())
{
announcer.AnnounceFailedAlreadyDisabled(selectedFeatureClass);
return;
}
selectedFeatureClass.static.DisableMe();
// It is possible that this command itself is destroyed after above command
// so do the check just in case
if (IsAllocated()) {
announcer.AnnounceDisabledFeature(selectedFeatureName);
announcer.AnnounceDisabledFeature(selectedFeatureClass);
}
}
protected function ShowSelectedConfigs(bool showAllFeatures) {
protected function ShowSelectedConfigs(bool showAllFeatures)
{
local int i;
local array<Text> availableConfigs;
local MutableText configList;
local class<FeatureConfig> configClass;
if (showAllFeatures) {
if (showAllFeatures)
{
configClass = selectedFeatureClass.default.configClass;
if (configClass != none) {
availableConfigs = configClass.static.AvailableConfigs();
@ -218,7 +235,8 @@ protected function ShowSelectedConfigs(bool showAllFeatures) {
_.memory.FreeMany(availableConfigs);
return;
}
if (selectedConfigName != none) {
if (selectedConfigName != none)
{
ShowFeatureConfig(selectedConfigName);
return;
}
@ -230,7 +248,8 @@ protected function ShowSelectedConfigs(bool showAllFeatures) {
_.memory.Free(configList);
}
protected function ShowFeatureConfig(BaseText configName) {
protected function ShowFeatureConfig(BaseText configName)
{
local MutableText dataAsJSON;
local HashTable currentData, pendingData;
@ -238,24 +257,26 @@ protected function ShowFeatureConfig(BaseText configName) {
return;
}
currentData = GetCurrentConfigData(configName);
if (currentData == none) {
if (currentData == none)
{
announcer.AnnounceFailedNoDataForConfig(
selectedFeatureName,
selectedFeatureClass,
configName);
return;
}
// Display current data
dataAsJSON = _.json.PrettyPrint(currentData);
announcer.AnnounceCurrentConfig(selectedFeatureName, configName);
announcer.AnnounceCurrentConfig(selectedFeatureClass, configName);
callerConsole.Flush().WriteLine(dataAsJSON);
_.memory.Free(dataAsJSON);
// Display pending data
pendingConfigs.SelectConfig(selectedFeatureClass, configName);
pendingData = pendingConfigs.GetPendingConfigData();
if (pendingData != none) {
if (pendingData != none)
{
dataAsJSON = _.json.PrettyPrint(pendingData);
announcer.AnnouncePendingConfig(
selectedFeatureName,
selectedFeatureClass,
configName);
callerConsole.Flush().WriteLine(dataAsJSON);
_.memory.Free(dataAsJSON);
@ -264,17 +285,20 @@ protected function ShowFeatureConfig(BaseText configName) {
_.memory.Free(currentData);
}
protected function Text PickConfigBasedOnParameter() {
protected function Text PickConfigBasedOnParameter()
{
local Text resolvedConfig;
local class<FeatureConfig> configClass;
configClass = selectedFeatureClass.default.configClass;
if (configClass == none) {
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
if (configClass == none)
{
announcer.AnnounceFailedNoConfigClass(selectedFeatureClass);
return none;
}
// If config was specified - simply check that it exists
if (selectedConfigName != none) {
if (selectedConfigName != none)
{
if (configClass.static.Exists(selectedConfigName)) {
return selectedConfigName.Copy();
}
@ -284,28 +308,36 @@ protected function Text PickConfigBasedOnParameter() {
// If it wasn't specified - try auto config instead
resolvedConfig = configClass.static.GetAutoEnabledConfig();
if (resolvedConfig == none) {
announcer.AnnounceFailedNoConfigProvided(selectedFeatureName);
announcer.AnnounceFailedNoConfigProvided(selectedFeatureClass);
}
return resolvedConfig;
}
protected function class<Feature> LoadFeatureClass(BaseText featureClassName) {
protected function class<Feature> LoadFeatureClass(BaseText featureName)
{
local Text featureClassName;
local class<Feature> featureClass;
if (featureClassName == none) {
if (featureName == none) {
return none;
}
if (featureName.StartsWith(P("$"))) {
featureClassName = _.alias.ResolveFeature(featureName, true);
}
else {
featureClassName = featureName.Copy();
}
featureClass = class<Feature>(_.memory.LoadClass(featureClassName));
if (featureClass == none) {
announcer.AnnounceFailedToLoadFeatureClass(featureClassName);
announcer.AnnounceFailedToLoadFeatureClass(featureName);
}
_.memory.Free(featureClassName);
return featureClass;
}
protected function ShowAllFeatures() {
protected function ShowAllFeatures()
{
local int i;
local array< class<Feature> > availableFeatures;
availableFeatures = _.environment.GetAvailableFeatures();
for (i = 0; i < availableFeatures.length; i ++) {
ShowFeature(availableFeatures[i]);
@ -338,9 +370,10 @@ protected function ShowFeature(class<Feature> featureClass)
_.memory.Free(configList);
}
protected function MutableText PrintConfigList(class<Feature> featureClass) {
protected function MutableText PrintConfigList(class<Feature> featureClass)
{
local int i;
local Text autoConfig, enabledConfig;
local Text autoConfig;
local ListBuilder configList;
local MutableText result, nextConfig;
local array<Text> availableConfigs;
@ -351,34 +384,31 @@ protected function MutableText PrintConfigList(class<Feature> featureClass) {
if (configClass == none) return none;
availableConfigs = configClass.static.AvailableConfigs();
enabledConfig = featureClass.static.GetCurrentConfig();
autoConfig = configClass.static.GetAutoEnabledConfig();
configList = ListBuilder(_.memory.Allocate(class'ListBuilder'));
for (i = 0; i < availableConfigs.length; i += 1) {
for (i = 0; i < availableConfigs.length; i += 1)
{
nextConfig = availableConfigs[i].MutableCopy();
if (enabledConfig != none && enabledConfig.Compare(nextConfig, SCASE_INSENSITIVE)) {
nextConfig.ChangeDefaultColor(_.color.TextPositive);
}
if (pendingConfigs.HasPendingConfigFor(featureClass, nextConfig)) {
nextConfig.Append(F("{$TextEmphasis *}"));
}
configList.Item(nextConfig);
_.memory.Free(nextConfig);
if (autoConfig != none && autoConfig.Compare(availableConfigs[i], SCASE_INSENSITIVE)) {
if (autoConfig.Compare(enabledConfig, SCASE_INSENSITIVE)) {
if ( autoConfig != none
&& autoConfig.Compare(availableConfigs[i], SCASE_INSENSITIVE))
{
configList.Comment(F("{$TextPositive auto enabled}"));
} else {
configList.Comment(F("{$TextNegative auto enabled}"));
}
}
}
result = configList.GetMutable();
_.memory.Free3(configList, autoConfig, enabledConfig);
_.memory.Free(configList);
_.memory.Free(autoConfig);
_.memory.FreeMany(availableConfigs);
return result;
}
protected function MutableText PrettyPrintValueAt(BaseText pathToValue) {
protected function MutableText PrettyPrintValueAt(BaseText pathToValue)
{
local MutableText printedValue;
local AcediaObject value;
local HashTable relevantData;
@ -390,7 +420,8 @@ protected function MutableText PrettyPrintValueAt(BaseText pathToValue) {
if (relevantData != none) {
value = relevantData.GetItemBy(pathToValue);
}
if (value != none) {
if (value != none)
{
printedValue = _.json.PrettyPrint(value);
_.memory.Free(value);
}
@ -398,14 +429,15 @@ protected function MutableText PrettyPrintValueAt(BaseText pathToValue) {
return printedValue;
}
protected function EditFeatureConfig(BaseText pathToValue, AcediaObject newValue, bool saveConfig) {
protected function EditFeatureConfig(
BaseText pathToValue,
BaseText newValue,
bool saveConfig)
{
local MutableText printedOldValue;
local MutableText printedNewValue;
local PendingConfigsTool.PendingConfigToolResult error;
if (selectedFeatureClass == none) {
return;
}
printedOldValue = PrettyPrintValueAt(pathToValue);
error = pendingConfigs.EditConfig(pathToValue, newValue);
if (error == PCTE_None) {
@ -416,20 +448,26 @@ protected function EditFeatureConfig(BaseText pathToValue, AcediaObject newValue
}
else if (error == PCTE_ExpectedObject) {
announcer.AnnounceFailedExpectedObject();
} else if (error == PCTE_BadPointer) {
}
else if (error == PCTE_BadPointer)
{
announcer.AnnounceFailedBadPointer(
selectedFeatureName,
selectedFeatureClass,
selectedConfigName,
pathToValue);
} else if (printedOldValue == none) {
}
else if (printedOldValue == none)
{
announcer.AnnounceConfigNewValue(
selectedFeatureName,
selectedFeatureClass,
selectedConfigName,
pathToValue,
printedNewValue);
} else {
}
else
{
announcer.AnnounceConfigEdited(
selectedFeatureName,
selectedFeatureClass,
selectedConfigName,
pathToValue,
printedOldValue,
@ -440,22 +478,23 @@ protected function EditFeatureConfig(BaseText pathToValue, AcediaObject newValue
}
_.memory.Free(printedOldValue);
_.memory.Free(printedNewValue);
_.memory.Free(pathToValue);
_.memory.Free(newValue);
}
protected function SaveFeatureConfig() {
protected function SaveFeatureConfig()
{
local BaseText enabledConfigName;
local HashTable pendingData;
local class<FeatureConfig> configClass;
configClass = selectedFeatureClass.default.configClass;
if (configClass == none) {
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
if (configClass == none)
{
announcer.AnnounceFailedNoConfigClass(selectedFeatureClass);
return;
}
pendingData = pendingConfigs.GetPendingConfigData();
if (pendingData == none) {
if (pendingData == none)
{
announcer.AnnounceFailedPendingConfigMissing(selectedConfigName);
return;
}
@ -464,11 +503,13 @@ protected function SaveFeatureConfig() {
configClass.static.SaveData(selectedConfigName, pendingData);
// Re-apply config if it is active?
enabledConfigName = selectedFeatureClass.static.GetCurrentConfig();
if (selectedConfigName.Compare(enabledConfigName, SCASE_INSENSITIVE)) {
if (selectedConfigName.Compare(enabledConfigName, SCASE_INSENSITIVE))
{
selectedFeatureClass.static.EnableMe(selectedConfigName);
announcer.AnnouncePublicPendingConfigSaved(selectedFeatureName);
} else {
announcer.AnnouncePrivatePendingConfigSaved(selectedFeatureName, selectedConfigName);
announcer.AnnouncePublicPendingConfigSaved(selectedFeatureClass);
}
else {
announcer.AnnouncePrivatePendingConfigSaved(selectedFeatureClass);
}
_.memory.Free(enabledConfigName);
pendingData.FreeSelf();
@ -476,104 +517,128 @@ protected function SaveFeatureConfig() {
return;
}
protected function NewFeatureConfig() {
protected function NewFeatureConfig()
{
local BaseText enabledConfigName;
local class<FeatureConfig> configClass;
configClass = selectedFeatureClass.default.configClass;
if (configClass == none) {
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
if (configClass == none)
{
announcer.AnnounceFailedNoConfigClass(selectedFeatureClass);
return;
}
if (configClass.static.Exists(selectedConfigName)) {
announcer.AnnounceFailedConfigAlreadyExists(selectedFeatureName, selectedConfigName);
if (configClass.static.Exists(selectedConfigName))
{
announcer.AnnounceFailedConfigAlreadyExists(
selectedFeatureClass,
selectedConfigName);
return;
}
if (!configClass.static.NewConfig(selectedConfigName)) {
if (!configClass.static.NewConfig(selectedConfigName))
{
announcer.AnnounceFailedBadConfigName(selectedConfigName);
return;
}
enabledConfigName = selectedFeatureClass.static.GetCurrentConfig();
if (selectedConfigName.Compare(enabledConfigName, SCASE_INSENSITIVE)) {
if (selectedConfigName.Compare(enabledConfigName, SCASE_INSENSITIVE))
{
selectedFeatureClass.static.EnableMe(selectedConfigName);
announcer.AnnouncePublicPendingConfigSaved(selectedFeatureName);
announcer.AnnouncePublicPendingConfigSaved(selectedFeatureClass);
}
_.memory.Free(enabledConfigName);
announcer.AnnounceConfigCreated(selectedFeatureName, selectedConfigName);
announcer.AnnounceConfigCreated(selectedFeatureClass, selectedConfigName);
}
protected function RemoveFeatureConfig() {
protected function RemoveFeatureConfig()
{
local class<FeatureConfig> configClass;
configClass = selectedFeatureClass.default.configClass;
if (configClass == none) {
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
if (configClass == none)
{
announcer.AnnounceFailedNoConfigClass(selectedFeatureClass);
return;
}
if (!configClass.static.Exists(selectedConfigName)) {
if (!configClass.static.Exists(selectedConfigName))
{
announcer.AnnounceFailedConfigDoesNotExist(
selectedFeatureName,
selectedFeatureClass,
selectedConfigName);
return;
}
pendingConfigs.RemoveConfig();
configClass.static.DeleteConfig(selectedConfigName);
announcer.AnnounceConfigRemoved(selectedFeatureName, selectedConfigName);
announcer.AnnounceConfigRemoved(selectedFeatureClass, selectedConfigName);
}
protected function SetAutoFeatureConfig() {
protected function SetAutoFeatureConfig()
{
local Text currentAutoEnabledConfig;
local class<FeatureConfig> configClass;
configClass = selectedFeatureClass.default.configClass;
if (configClass == none) {
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
if (configClass == none)
{
announcer.AnnounceFailedNoConfigClass(selectedFeatureClass);
return;
}
if (selectedConfigName != none && !configClass.static.Exists(selectedConfigName)) {
announcer.AnnounceFailedConfigDoesNotExist(selectedFeatureName, selectedConfigName);
if ( selectedConfigName != none
&& !configClass.static.Exists(selectedConfigName))
{
announcer.AnnounceFailedConfigDoesNotExist(
selectedFeatureClass,
selectedConfigName);
return;
}
currentAutoEnabledConfig = configClass.static.GetAutoEnabledConfig();
if (selectedConfigName == none && currentAutoEnabledConfig == none) {
announcer.AnnounceFailedAlreadyNoAutoEnabled(selectedFeatureName);
announcer.AnnounceFailedAlreadyNoAutoEnabled(selectedFeatureClass);
}
else if (selectedConfigName != none &&
selectedConfigName.Compare(currentAutoEnabledConfig, SCASE_INSENSITIVE)) {
selectedConfigName.Compare(currentAutoEnabledConfig, SCASE_INSENSITIVE))
{
announcer.AnnounceFailedAlreadySameAutoEnabled(
selectedFeatureName,
selectedFeatureClass,
selectedConfigName);
} else {
}
else
{
configClass.static.SetAutoEnabledConfig(selectedConfigName);
if (selectedConfigName != none) {
if (selectedConfigName != none)
{
announcer.AnnounceAutoEnabledConfig(
selectedFeatureName,
selectedFeatureClass,
selectedConfigName);
} else {
announcer.AnnounceRemovedAutoEnabledConfig(selectedFeatureName);
}
else {
announcer.AnnounceRemovedAutoEnabledConfig(selectedFeatureClass);
}
}
_.memory.Free(currentAutoEnabledConfig);
}
private function HashTable GetCurrentConfigData(BaseText configName) {
private function HashTable GetCurrentConfigData(BaseText configName)
{
local class<FeatureConfig> configClass;
if (configName == none) {
return none;
}
configClass = selectedFeatureClass.default.configClass;
if (configClass == none) {
announcer.AnnounceFailedNoConfigClass(selectedFeatureName);
if (configClass == none)
{
announcer.AnnounceFailedNoConfigClass(selectedFeatureClass);
return none;
}
return configClass.static.LoadData(configName);
}
private function HashTable GetCurrentSelectedConfigData() {
private function HashTable GetCurrentSelectedConfigData()
{
return GetCurrentConfigData(selectedConfigName);
}
defaultproperties {
preferredName = "feature"
defaultproperties
{
}

102
sources/Commands/ACommandFeature_Announcer.uc

@ -75,7 +75,7 @@ protected function Finalizer()
}
public final function AnnounceEnabledFeature(
BaseText featureName,
class<Feature> featureClass,
BaseText configName)
{
local int i;
@ -93,12 +93,12 @@ public final function AnnounceEnabledFeature(
}
templates = MakeArray(enabledFeature);
for (i = 0; i < templates.length; i += 1) {
templates[i].Reset().Arg(featureName).Arg(configName);
templates[i].Reset().ArgClass(featureClass).Arg(configName);
}
MakeAnnouncement(enabledFeature);
}
public final function AnnounceDisabledFeature(BaseText featureName)
public final function AnnounceDisabledFeature(class<Feature> featureClass)
{
local int i;
local array<TextTemplate> templates;
@ -114,13 +114,13 @@ public final function AnnounceDisabledFeature(BaseText featureName)
}
templates = MakeArray(disabledFeature);
for (i = 0; i < templates.length; i += 1) {
templates[i].Reset().Arg(featureName);
templates[i].Reset().ArgClass(featureClass);
}
MakeAnnouncement(disabledFeature);
}
public final function AnnounceSwappedConfig(
BaseText featureName,
class<Feature> featureClass,
BaseText oldConfig,
BaseText newConfig)
{
@ -142,7 +142,7 @@ public final function AnnounceSwappedConfig(
{
templates[i]
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(oldConfig)
.Arg(newConfig);
}
@ -150,7 +150,7 @@ public final function AnnounceSwappedConfig(
}
public final function AnnouncePublicPendingConfigSaved(
BaseText featureName)
class<Feature> featureClass)
{
local int i;
local array<TextTemplate> templates;
@ -167,29 +167,29 @@ public final function AnnouncePublicPendingConfigSaved(
}
templates = MakeArray(pendingConfigSavedPublic);
for (i = 0; i < templates.length; i += 1) {
templates[i].Reset().Arg(featureName);
templates[i].Reset().ArgClass(featureClass);
}
MakeAnnouncement(pendingConfigSavedPublic);
}
public final function AnnouncePrivatePendingConfigSaved(BaseText featureName, BaseText configName)
public final function AnnouncePrivatePendingConfigSaved(
class<Feature> featureClass)
{
if (!pendingConfigSavedPrivate.initialized)
{
pendingConfigSavedPrivate.initialized = true;
pendingConfigSavedPrivate.toSelfReport = _.text.MakeTemplate_S(
"Config \"%2\" for feature {$TextEmphasis `%1`} was"
"Active config for feature {$TextEmphasis `%1`} was"
@ "{$TextNeutral modified}");
}
pendingConfigSavedPrivate.toSelfReport
.Reset()
.Arg(featureName)
.Arg(configName);
.ArgClass(featureClass);
MakeAnnouncement(pendingConfigSavedPrivate);
}
public final function AnnounceCurrentConfig(
BaseText featureName,
class<Feature> featureClass,
BaseText config)
{
if (!showCurrentConfig.initialized)
@ -200,13 +200,13 @@ public final function AnnounceCurrentConfig(
}
showCurrentConfig.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config);
MakeAnnouncement(showCurrentConfig);
}
public final function AnnouncePendingConfig(
BaseText featureName,
class<Feature> featureClass,
BaseText config)
{
if (!showPendingConfig.initialized)
@ -217,13 +217,13 @@ public final function AnnouncePendingConfig(
}
showPendingConfig.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config);
MakeAnnouncement(showPendingConfig);
}
public final function AnnounceConfigCreated(
BaseText featureName,
class<Feature> featureClass,
BaseText config)
{
if (!configCreated.initialized)
@ -235,13 +235,13 @@ public final function AnnounceConfigCreated(
}
configCreated.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config);
MakeAnnouncement(configCreated);
}
public final function AnnounceConfigRemoved(
BaseText featureName,
class<Feature> featureClass,
BaseText config)
{
if (!configRemoved.initialized)
@ -253,13 +253,13 @@ public final function AnnounceConfigRemoved(
}
configRemoved.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config);
MakeAnnouncement(configRemoved);
}
public final function AnnounceConfigEdited(
BaseText featureName,
class<Feature> featureClass,
BaseText config,
BaseText pathToValue,
BaseText oldValue,
@ -275,7 +275,7 @@ public final function AnnounceConfigEdited(
}
configEdited.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config)
.Arg(pathToValue)
.Arg(oldValue)
@ -284,7 +284,7 @@ public final function AnnounceConfigEdited(
}
public final function AnnounceConfigNewValue(
BaseText featureName,
class<Feature> featureClass,
BaseText config,
BaseText pathToValue,
BaseText newValue)
@ -298,7 +298,7 @@ public final function AnnounceConfigNewValue(
}
configEditedNew.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config)
.Arg(pathToValue)
.Arg(newValue);
@ -306,7 +306,7 @@ public final function AnnounceConfigNewValue(
}
public final function AnnounceAutoEnabledConfig(
BaseText featureName,
class<Feature> featureClass,
BaseText config)
{
if (!autoEnabled.initialized)
@ -318,13 +318,13 @@ public final function AnnounceAutoEnabledConfig(
}
autoEnabled.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config);
MakeAnnouncement(autoEnabled);
}
public final function AnnounceRemovedAutoEnabledConfig(
BaseText featureName)
class<Feature> featureClass)
{
if (!removedAutoEnabled.initialized)
{
@ -335,12 +335,12 @@ public final function AnnounceRemovedAutoEnabledConfig(
}
removedAutoEnabled.toSelfReport
.Reset()
.Arg(featureName);
.ArgClass(featureClass);
MakeAnnouncement(removedAutoEnabled);
}
public final function AnnounceFailedAlreadyNoAutoEnabled(
BaseText featureName)
class<Feature> featureClass)
{
if (!failedAlreadyNoAutoEnabled.initialized)
{
@ -352,12 +352,12 @@ public final function AnnounceFailedAlreadyNoAutoEnabled(
}
failedAlreadyNoAutoEnabled.toSelfReport
.Reset()
.Arg(featureName);
.ArgClass(featureClass);
MakeAnnouncement(failedAlreadyNoAutoEnabled);
}
public final function AnnounceFailedAlreadySameAutoEnabled(
BaseText featureName,
class<Feature> featureClass,
BaseText config)
{
if (!failedAlreadySameAutoEnabled.initialized)
@ -370,13 +370,13 @@ public final function AnnounceFailedAlreadySameAutoEnabled(
}
failedAlreadySameAutoEnabled.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config);
MakeAnnouncement(failedAlreadySameAutoEnabled);
}
public final function AnnounceFailedConfigAlreadyExists(
BaseText featureName,
class<Feature> featureClass,
BaseText config)
{
if (!failedConfigAlreadyExists.initialized)
@ -388,13 +388,13 @@ public final function AnnounceFailedConfigAlreadyExists(
}
failedConfigAlreadyExists.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config);
MakeAnnouncement(failedConfigAlreadyExists);
}
public final function AnnounceFailedConfigDoesNotExist(
BaseText featureName,
public final function AnnounceFailedConfigDoesNotExist(
class<Feature> featureClass,
BaseText config)
{
if (!failedConfigDoesNotExists.initialized)
@ -406,7 +406,7 @@ public final function AnnounceFailedConfigDoesNotExist(
}
failedConfigDoesNotExists.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config);
MakeAnnouncement(failedConfigDoesNotExists);
}
@ -424,7 +424,7 @@ public final function AnnounceFailedToLoadFeatureClass(BaseText failedClassName)
}
public final function AnnounceFailedNoConfigProvided(
BaseText featureName)
class<Feature> featureClass)
{
if (!failedNoConfigProvided.initialized)
{
@ -433,7 +433,7 @@ public final function AnnounceFailedNoConfigProvided(
"{$TextFailure No config specified} and {$TextFailure no"
@ "auto-enabled config} exists for feature {$TextEmphasis `%1`}");
}
failedNoConfigProvided.toSelfReport.Reset().Arg(featureName);
failedNoConfigProvided.toSelfReport.Reset().ArgClass(featureClass);
MakeAnnouncement(failedNoConfigProvided);
}
@ -463,7 +463,7 @@ public final function AnnounceFailedPendingConfigMissing(BaseText config)
}
public final function AnnounceFailedCannotEnableFeature(
BaseText featureName,
class<Feature> featureClass,
BaseText config)
{
if (!failedCannotEnableFeature.initialized)
@ -475,13 +475,13 @@ public final function AnnounceFailedCannotEnableFeature(
}
failedCannotEnableFeature.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config);
MakeAnnouncement(failedCannotEnableFeature);
}
public final function AnnounceFailedNoConfigClass(
BaseText featureName)
class<Feature> featureClass)
{
if (!failedNoConfigClass.initialized)
{
@ -491,7 +491,7 @@ public final function AnnounceFailedNoConfigClass(
@ "class! This is most likely caused by its faulty"
@ "implementation");
}
failedNoConfigClass.toSelfReport.Reset().Arg(featureName);
failedNoConfigClass.toSelfReport.Reset().ArgClass(featureClass);
MakeAnnouncement(failedNoConfigClass);
}
@ -508,7 +508,7 @@ public final function AnnounceFailedBadConfigName(BaseText configName)
}
public final function AnnounceFailedAlreadyDisabled(
BaseText featureName)
class<Feature> featureClass)
{
if (!failedAlreadyDisabled.initialized)
{
@ -517,12 +517,12 @@ public final function AnnounceFailedAlreadyDisabled(
"{$TextFailure Cannot disable} feature {$TextEmphasis `%1`}: it is"
@ "already {$TextNegative disabled}");
}
failedAlreadyDisabled.toSelfReport.Reset().Arg(featureName);
failedAlreadyDisabled.toSelfReport.Reset().ArgClass(featureClass);
MakeAnnouncement(failedAlreadyDisabled);
}
public final function AnnounceFailedAlreadyEnabled(
BaseText featureName,
class<Feature> featureClass,
BaseText config)
{
if (!failedAlreadyEnabled.initialized)
@ -534,13 +534,13 @@ public final function AnnounceFailedAlreadyEnabled(
}
failedAlreadyEnabled.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config);
MakeAnnouncement(failedAlreadyEnabled);
}
public final function AnnounceFailedNoDataForConfig(
BaseText featureName,
class<Feature> featureClass,
BaseText config)
{
if (!failedNoDataForConfig.initialized)
@ -552,7 +552,7 @@ public final function AnnounceFailedNoDataForConfig(
}
failedNoDataForConfig.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config);
MakeAnnouncement(failedNoDataForConfig);
}
@ -570,7 +570,7 @@ public final function AnnounceFailedExpectedObject()
}
public final function AnnounceFailedBadPointer(
BaseText featureName,
class<Feature> featureClass,
BaseText config,
BaseText pointer)
{
@ -583,7 +583,7 @@ public final function AnnounceFailedBadPointer(
}
failedBadPointer.toSelfReport
.Reset()
.Arg(featureName)
.ArgClass(featureClass)
.Arg(config)
.Arg(pointer);
MakeAnnouncement(failedBadPointer);

30
sources/Commands/ACommandGod.uc

@ -46,21 +46,21 @@ protected function Finalizer()
protected function BuildData(CommandDataBuilder builder)
{
builder.Group(P("gameplay"));
builder.Summary(P("Command for making player immortal."));
builder.RequireTarget();
builder.Describe(P("Gives targeted players god status, making them"
builder.Name(P("god")).Group(P("gameplay"))
.Summary(P("Command for making player immortal."));
builder.RequireTarget()
.Describe(P("Gives targeted players god status, making them"
@ "invincible."));
builder.SubCommand(P("list"));
builder.Describe(P("Reports godhood status of targeted players."));
builder.SubCommand(P("strip"));
builder.Describe(P("Strips targeted players from the godhood status."));
builder.Option(P("demi"));
builder.Describe(P("This flag makes targeted players \"demigods\" instead -"
builder.SubCommand(P("list"))
.Describe(P("Reports godhood status of targeted players."));
builder.SubCommand(P("strip"))
.Describe(P("Strips targeted players from the godhood status."));
builder.Option(P("demi"))
.Describe(P("This flag makes targeted players \"demigods\" instead -"
@ "they still cannot die, but they can take any non-lethal"
@ "damage."));
builder.Option(P("unmovable"));
builder.Describe(P("This flag also prevents targeted players from being"
builder.Option(P("unmovable"))
.Describe(P("This flag also prevents targeted players from being"
@ "affected by the momentum trasnferred from damaging attacks."));
announcer = ACommandGod_Announcer(
_.memory.Allocate(class'ACommandGod_Announcer'));
@ -69,9 +69,8 @@ protected function BuildData(CommandDataBuilder builder)
protected function ExecutedFor(
EPlayer target,
CallData arguments,
EPlayer instigator,
CommandPermissions permissions
) {
EPlayer instigator)
{
local GodStatus newGodStatus;
announcer.Setup(target, instigator, othersConsole);
@ -216,7 +215,6 @@ private final function UpdateHealthSignalConnection()
defaultproperties
{
preferredName = "god"
TDAMAGE = 0
stringConstants(0) = "damage"
TMOMENTUM = 1

66
sources/Commands/ACommandInventory.uc

@ -34,57 +34,57 @@ var protected const int TLISTS_SKIPPED;
protected function BuildData(CommandDataBuilder builder)
{
builder.Group(P("gameplay"));
builder.Summary(P("Manages player's inventory."));
builder.Describe(P("Command for displaying and editing players' inventories."
builder.Name(T(TINVENTORY)).Group(P("gameplay"))
.Summary(P("Manages player's inventory."))
.Describe(P("Command for displaying and editing players' inventories."
@ "If called without specifying subcommand - simply displays"
@ "targeted player's inventory."));
builder.RequireTarget();
builder.SubCommand(T(TADD));
builder.OptionalParams();
builder.ParamTextList(T(TITEMS));
builder.Describe(P("This command adds items (based on listed templates) to"
builder.SubCommand(T(TADD))
.OptionalParams()
.ParamTextList(T(TITEMS))
.Describe(P("This command adds items (based on listed templates) to"
@ "the targeted player's inventory."
@ "Instead of templates item aliases can be specified."));
builder.SubCommand(T(TREMOVE));
builder.OptionalParams();
builder.ParamTextList(T(TITEMS));
builder.Describe(P("This command removes items (based on listed templates)"
builder.SubCommand(T(TREMOVE))
.OptionalParams()
.ParamTextList(T(TITEMS))
.Describe(P("This command removes items (based on listed templates)"
@ "from the targeted player's inventory."
@ "Instead of templates item aliases can be specified."));
builder.SubCommand(T(TSET));
builder.OptionalParams();
builder.ParamTextList(T(TITEMS));
builder.Describe(P("This command acts like combination of two commands -"
builder.SubCommand(T(TSET))
.OptionalParams()
.ParamTextList(T(TITEMS))
.Describe(P("This command acts like combination of two commands -"
@ "first removing all items from the player's current inventory and"
@ "then adding specified items. first clears inventory"
@ "(based on specified options) and then "));
builder.Option(T(TEQUIP));
builder.Describe(F("Affect items currently equipped by the targeted player."
builder.Option(T(TEQUIP))
.Describe(F("Affect items currently equipped by the targeted player."
@ "Releveant for a {$TextEmphasis remove} subcommand."));
builder.Option(T(TLIST));
builder.Describe(P("Include weapons from specified group into the list."));
builder.ParamTextList(T(TLISTS_NAMES));
builder.Option(T(TAMMO));
builder.Describe(P("When adding weapons - signals that their"
builder.Option(T(TLIST))
.Describe(P("Include weapons from specified group into the list."))
.ParamTextList(T(TLISTS_NAMES));
builder.Option(T(TAMMO))
.Describe(P("When adding weapons - signals that their"
@ "ammo / charge / whatever has to be filled after addition."));
builder.Option(T(TKEEP));
builder.Describe(F("Removing items by default means simply destroying them."
builder.Option(T(TKEEP))
.Describe(F("Removing items by default means simply destroying them."
@ "This flag makes command to try and keep them in some form."
@ "Success for all items is not guaranteed."));
builder.Option(T(THIDDEN));
builder.Describe(F("Some of the items in the inventory are"
builder.Option(T(THIDDEN))
.Describe(F("Some of the items in the inventory are"
@ "{$TextEmphasis hidden} and are not supposed to be seem by"
@ "the player. To avoid weird behavior, {$TextEmphasis inventory}"
@ "command by default ignores them when affecting groups of items"
@ "(like when removing all items) unless they're directly"
@ "specified. This flag tells it to also affect hidden items."));
builder.Option(T(TFORCE));
builder.Describe(P("Sometimes adding and removing items is impossible due to"
builder.Option(T(TFORCE))
.Describe(P("Sometimes adding and removing items is impossible due to"
@ "the limitations imposed by the game. This option allows to"
@ "ignore some of those limitation."));
builder.Option(T(TALL), P("A"));
builder.Describe(F("This flag is used when removing items. If user has"
builder.Option(T(TALL), P("A"))
.Describe(F("This flag is used when removing items. If user has"
@ "specified any weapon templates - it means"
@ "\"remove all items with these tempaltes from inventory\","
@ "but if user has not specified any templated it simply means"
@ -94,9 +94,8 @@ protected function BuildData(CommandDataBuilder builder)
protected function ExecutedFor(
EPlayer target,
CallData arguments,
EPlayer instigator,
CommandPermissions permissions
) {
EPlayer instigator)
{
local InventoryTool tool;
local ArrayList itemsArray, specifiedLists;
LoadUserFlags(arguments.options);
@ -287,7 +286,6 @@ protected function array<Text> LoadItemsList(
defaultproperties
{
preferredName = "inventory"
TINVENTORY = 0
stringConstants(0) = "inventory"
TADD = 1

38
sources/Commands/ACommandNick.uc

@ -34,31 +34,30 @@ protected function Finalizer()
protected function BuildData(CommandDataBuilder builder)
{
builder.Group(P("gameplay"));
builder.Summary(P("Changes nickname."));
builder.Name(P("nick")).Group(P("gameplay"))
.Summary(P("Changes nickname."));
builder.RequireTarget();
builder.ParamRemainder(P("nick"));
builder.Describe(P("Changes nickname of targeted players to <nick>."));
builder.Option(P("plain"));
builder.Describe(P("Take nickname exactly as typed, without attempting to"
builder.ParamRemainder(P("nick"))
.Describe(P("Changes nickname of targeted players to <nick>."));
builder.Option(P("plain"))
.Describe(P("Take nickname exactly as typed, without attempting to"
@ "treat it like formatted string."));
builder.Option(P("fix"), P("f"));
builder.Describe(P("In case of a nickname with erroroneous formatting or"
builder.Option(P("fix"), P("f"))
.Describe(P("In case of a nickname with erroroneous formatting or"
@ "invalid default color (specified with `--color`),"
@ "try to fix/ignore it instead of simply rejecting it."));
builder.Option(P("color"));
builder.Describe(P("Color to use for the nickname. In case nickname is already"
@ "colored, this flag will only affects uncolored parts."));
builder.ParamText(P("default_color"));
builder.Option(P("color"))
.Describe(P("Color to use for the nickname. In case nickname is already"
@ "colored, this flag will only affects uncolored parts."))
.ParamText(P("default_color"));
announcer = ACommandNick_Announcer(
_.memory.Allocate(class'ACommandNick_Announcer'));
}
protected function Executed(
CallData arguments,
EPlayer callerPlayer,
CommandPermissions permissions
) {
EPlayer callerPlayer)
{
local Text givenName;
local array<FormattingErrorsReport.FormattedStringError> errors;
@ -90,9 +89,8 @@ protected function Executed(
protected function ExecutedFor(
EPlayer target,
CallData arguments,
EPlayer instigator,
CommandPermissions permissions
) {
EPlayer instigator)
{
local Text alteredVersion;
if (!foundErrors || arguments.options.HasKey(P("fix")))
@ -128,6 +126,6 @@ protected function bool TryChangeDefaultColor(BaseText specifiedColor)
return false;
}
defaultproperties {
preferredName = "nick"
defaultproperties
{
}

95
sources/Commands/ACommandSpawn.uc

@ -30,17 +30,17 @@ protected function Finalizer()
protected function BuildData(CommandDataBuilder builder)
{
builder.Group(P("debug"));
builder.Summary(P("Spawns new entity on the map."));
builder.ParamText(P("template"),, P("entity"));
builder.Describe(P("Spawns new entity based on the given template at the point"
builder.Name(P("spawn")).Group(P("debug"))
.Summary(P("Spawns new entity on the map."));
builder.ParamText(P("template"))
.Describe(P("Spawns new entity based on the given template at the point"
@ "player is currently looking at."));
builder.SubCommand(P("at"));
builder.ParamText(P("template"),, P("entity"));
builder.ParamNumber(P("x"));
builder.ParamNumber(P("y"));
builder.ParamNumber(P("z"));
builder.Describe(P("Spawns new entity based on the given template at"
builder.SubCommand(P("at"))
.ParamText(P("template"))
.ParamNumber(P("x"))
.ParamNumber(P("y"))
.ParamNumber(P("z"))
.Describe(P("Spawns new entity based on the given template at"
@ "the point, given by the coordinates"));
announcer = ACommandSpawn_Announcer(
_.memory.Allocate(class'ACommandSpawn_Announcer'));
@ -48,58 +48,61 @@ protected function BuildData(CommandDataBuilder builder)
protected function Executed(
CallData arguments,
EPlayer instigator,
CommandPermissions permissions
) {
local HashTable value;
EPlayer instigator)
{
local Text givenTemplate, template;
local Vector spawnLocation;
announcer.Setup(none, instigator, othersConsole);
value = arguments.parameters.GetHashTable(P("template"));
givenTemplate = arguments.parameters.GetText(P("template"));
if (givenTemplate.StartsWithS("$")) {
template = _.alias.ResolveEntity(givenTemplate, true);
}
else {
template = givenTemplate.Copy();
}
_.memory.Free(givenTemplate);
if (arguments.subCommandName.IsEmpty()) {
SpawnInInstigatorSight(instigator, value);
} else if (arguments.subCommandName.Compare(P("at"), SCASE_INSENSITIVE)) {
SpawnInInstigatorSight(instigator, template);
}
else if (arguments.subCommandName.Compare(P("at"), SCASE_INSENSITIVE))
{
spawnLocation.x = arguments.parameters.GetFloat(P("x"));
spawnLocation.y = arguments.parameters.GetFloat(P("y"));
spawnLocation.z = arguments.parameters.GetFloat(P("z"));
SpawnAt(instigator, value, spawnLocation);
SpawnAt(instigator, template, spawnLocation);
}
_.memory.Free(value);
_.memory.Free(template);
}
private final function SpawnAt(
EPlayer instigator,
HashTable value,
Vector spawnLocation
) {
local Text humanReadable, template;
BaseText template,
Vector spawnLocation)
{
local EPlaceable result;
humanReadable = value.GetText(P("alias"));
template = value.GetText(P("value"));
result = _server.kf.world.Spawn(template, spawnLocation);
if (result != none) {
announcer.AnnounceSpawned(humanReadable);
} else {
announcer.AnnounceSpawningFailed(humanReadable);
announcer.AnnounceSpawned(template);
}
else {
announcer.AnnounceSpawningFailed(template);
}
_.memory.Free2(humanReadable, result);
_.memory.Free(result);
}
private final function SpawnInInstigatorSight(
EPlayer instigator,
HashTable value
) {
BaseText template)
{
local EPlaceable result;
local Vector spawnLocation;
local TracingIterator iter;
local Text humanReadable, template;
humanReadable = value.GetText(P("alias"));
template = value.GetText(P("value"));
iter = _server.kf.world.TracePlayerSight(instigator);
iter.LeaveOnlyVisible();
if (iter.HasFinished()) {
if (iter.LeaveOnlyVisible().HasFinished())
{
announcer.AnnounceFailedTrace();
return;
}
@ -107,18 +110,22 @@ private final function SpawnInInstigatorSight(
result = _server.kf.world.Spawn(template, spawnLocation);
// Shift position back a little and try again;
// this should fix a ton of spawning failures
if (result == none) {
spawnLocation = spawnLocation + Normal(iter.GetTracingStart() - spawnLocation) * 100;
if (result == none)
{
spawnLocation = spawnLocation +
Normal(iter.GetTracingStart() - spawnLocation) * 100;
result = _server.kf.world.Spawn(template, spawnLocation);
}
if (result != none) {
announcer.AnnounceSpawned(humanReadable);
} else {
announcer.AnnounceSpawningFailed(humanReadable);
announcer.AnnounceSpawned(template);
}
_.memory.Free4(result, iter, humanReadable, result);
else {
announcer.AnnounceSpawningFailed(template);
}
_.memory.Free(result);
_.memory.Free(iter);
}
defaultproperties {
preferredName = "spawn"
defaultproperties
{
}

104
sources/Commands/ACommandTrader.uc

@ -38,60 +38,60 @@ protected function Finalizer()
protected function BuildData(CommandDataBuilder builder)
{
builder.Group(P("gameplay"));
builder.Summary(P("Manages trader time and available traders."));
builder.Describe(P("Enables of disables trading."));
builder.ParamBoolean(T(TENABLE));
builder.SubCommand(T(TTIME));
builder.Describe(F("Changes current trader time if numeric value is specified."
builder.Name(T(TTRADER)).Group(P("gameplay"))
.Summary(P("Manages trader time and available traders."))
.Describe(P("Enables of disables trading."))
.ParamBoolean(T(TENABLE));
builder.SubCommand(T(TTIME))
.Describe(F("Changes current trader time if numeric value is specified."
@ "You can also pause trader countdown by specifying"
@ "{$TextEmphasis pause} or turn it back on with"
@ "{$TextEmphasis unpause}."));
builder.ParamText(T(TTRADER_TIME));
builder.SubCommand(T(TLIST));
builder.Describe(P("Lists names of all available traders and"
@ "{$TextEmphasis unpause}."))
.ParamText(T(TTRADER_TIME));
builder.SubCommand(T(TLIST))
.Describe(P("Lists names of all available traders and"
@ "marks closest one to the caller."));
builder.SubCommand(T(TOPEN));
builder.Describe(P("Opens specified traders."));
builder.OptionalParams();
builder.ParamTextList(T(TTRADERS));
builder.SubCommand(T(TCLOSE));
builder.Describe(P("Closes specified traders."));
builder.OptionalParams();
builder.ParamTextList(T(TTRADERS));
builder.SubCommand(T(TAUTO_OPEN));
builder.Describe(P("Sets whether specified traders are open automatically."));
builder.ParamBoolean(T(TAUTO_OPEN_QUESTION));
builder.OptionalParams();
builder.ParamTextList(T(TTRADERS));
builder.SubCommand(T(TSELECT));
builder.Describe(P("Selects specified trader."));
builder.OptionalParams();
builder.ParamText(T(TTRADER));
builder.SubCommand(T(TBOOT));
builder.Describe(P("Boots all players from specified traders. If no traders"
@ "were specified - assumes that all of them should be affected."));
builder.OptionalParams();
builder.ParamTextList(T(TTRADERS));
builder.SubCommand(T(TENABLE));
builder.Describe(P("Enables specified traders."));
builder.OptionalParams();
builder.ParamTextList(T(TTRADERS));
builder.SubCommand(T(TDISABLE));
builder.Describe(P("Disables specified traders."));
builder.OptionalParams();
builder.ParamTextList(T(TTRADERS));
builder.Option(T(TALL));
builder.Describe(P("If sub-command targets shops, this flag will make it"
builder.SubCommand(T(TOPEN))
.Describe(P("Opens specified traders."))
.OptionalParams()
.ParamTextList(T(TTRADERS));
builder.SubCommand(T(TCLOSE))
.Describe(P("Closes specified traders."))
.OptionalParams()
.ParamTextList(T(TTRADERS));
builder.SubCommand(T(TAUTO_OPEN))
.Describe(P("Sets whether specified traders are open automatically."))
.ParamBoolean(T(TAUTO_OPEN_QUESTION))
.OptionalParams()
.ParamTextList(T(TTRADERS));
builder.SubCommand(T(TSELECT))
.Describe(P("Selects specified trader."))
.OptionalParams()
.ParamText(T(TTRADER));
builder.SubCommand(T(TBOOT))
.Describe(P("Boots all players from specified traders. If no traders"
@ "were specified - assumes that all of them should be affected."))
.OptionalParams()
.ParamTextList(T(TTRADERS));
builder.SubCommand(T(TENABLE))
.Describe(P("Enables specified traders."))
.OptionalParams()
.ParamTextList(T(TTRADERS));
builder.SubCommand(T(TDISABLE))
.Describe(P("Disables specified traders."))
.OptionalParams()
.ParamTextList(T(TTRADERS));
builder.Option(T(TALL))
.Describe(P("If sub-command targets shops, this flag will make it"
@ "target all the available shops."));
builder.Option(T(TCLOSEST));
builder.Describe(P("If sub-command targets shops, this flag will make it also"
builder.Option(T(TCLOSEST))
.Describe(P("If sub-command targets shops, this flag will make it also"
@ "target closest shop to the caller."));
builder.Option(T(TIGNORE_DOORS));
builder.Describe(F("When used with {$TextEmphasis select} sub-command, it will"
builder.Option(T(TIGNORE_DOORS))
.Describe(F("When used with {$TextEmphasis select} sub-command, it will"
@ "neither open or close doors."));
builder.Option(T(TIGNORE_PLAYERS), P("I"));
builder.Describe(P("Normally commands that close doors will automatically boot"
builder.Option(T(TIGNORE_PLAYERS), P("I"))
.Describe(P("Normally commands that close doors will automatically boot"
@ "players from inside to prevent locking them in. This flag forces"
@ "this command to leave players inside. However they can still be"
@ "booted out at the end of trading time. Also it is impossible to"
@ -100,11 +100,8 @@ protected function BuildData(CommandDataBuilder builder)
_.memory.Allocate(class'ACommandTrader_Announcer'));
}
protected function Executed(
CallData arguments,
EPlayer instigator,
CommandPermissions permissions
) {
protected function Executed(CallData arguments, EPlayer instigator)
{
local bool newTradingStatus;
announcer.Setup(none, instigator, othersConsole);
@ -635,7 +632,6 @@ protected function WriteTraderTags(ETrader traderToWrite, bool isClosest)
defaultproperties
{
preferredName = "trader"
TLIST = 0
stringConstants(0) = "list"
TOPEN = 1

140
sources/Commands/ACommandUserData.uc

@ -1,6 +1,6 @@
/**
* Command for changing amount of money players have.
* Copyright 2022-2023 Anton Tarasenko
* Copyright 2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
@ -21,23 +21,24 @@ class ACommandUserData extends Command;
var private array<EPlayer> playerQueue;
// TODO: Finish this command after JSON parameters are added
protected function BuildData(CommandDataBuilder builder)
{
builder.Group(P("admin"));
builder.Summary(P("Allows to read and write custom user data for players."));
builder.Name(P("userdata")).Group(P("admin"))
.Summary(P("Allows to read and write custom user data for players."));
builder.RequireTarget();
builder.ParamText(P("groupName"));
builder.OptionalParams();
builder.ParamText(P("dataName"));
builder.Describe(F("Reads user data stored for targeted user under group"
builder.ParamText(P("groupName"))
.OptionalParams()
.ParamText(P("dataName"))
.Describe(P("Reads user data stored for targeted user under group"
@ "{$TextEmphasis `groupName`} and name"
@ "{$TextEmphasis `dataName`}. If {$TextEmphasis `dataName`} is"
@ "omitted, the data inside the whole group will be read."));
builder.SubCommand(P("write"));
builder.ParamText(P("groupName"));
builder.ParamText(P("dataName"));
builder.ParamJSON(P("newData"));
builder.Describe(F("Stores new user data {$TextEmphasis `newData`} for"
@ "omitted, the data inside the whjole group will be read."));
builder.SubCommand(P("write"))
.ParamText(P("groupName"))
.ParamText(P("dataName"))
.ParamObject(P("newData"))
.Describe(P("Stores new user data {$TextEmphasis `newData`} for"
@ "targeted user under group {$TextEmphasis `groupName`} and name"
@ "{$TextEmphasis `dataName`}."));
}
@ -45,85 +46,74 @@ protected function BuildData(CommandDataBuilder builder)
protected function ExecutedFor(
EPlayer target,
CallData arguments,
EPlayer instigator,
CommandPermissions permissions
) {
EPlayer instigator)
{
local AcediaObject userData;
local Text groupName, dataName;
groupName = arguments.parameters.GetText(P("groupName"));
dataName = arguments.parameters.GetText(P("dataName"));
userData = arguments.parameters.GetItem(P("newData"));
if (arguments.subCommandName.IsEmpty()) {
ReadUserData(target, groupName, dataName);
if (arguments.subCommandName.IsEmpty())
{
target
.GetIdentity()
.ReadPersistentData(
arguments.parameters.GetText(P("groupName")),
arguments.parameters.GetText(P("dataName")))
.connect = UserDataRead;
}
else {
WriteUserData(target, groupName, dataName, userData);
else
{
userData = arguments.parameters.GetHashTable(P("newData"));
target
.GetIdentity()
.WritePersistentData(
arguments.parameters.GetText(P("groupName")),
arguments.parameters.GetText(P("dataName")),
userData);
}
_.memory.Free(dataName);
_.memory.Free(groupName);
playerQueue[playerQueue.length] = target;
target.NewRef();
}
private final function ReadUserData(
EPlayer targetPlayer,
BaseText groupName,
BaseText dataName)
private final function UserDataRead(
Database.DBQueryResult result,
AcediaObject userData,
Database source)
{
local User identity;
local AcediaObject rawData;
local MutableText dataAsJSON;
local Text targetPlayerName;
local EPlayer targetPlayer;
local MutableText asJSON;
identity = targetPlayer.GetIdentity();
if (identity == none) {
if (playerQueue.length <= 0)
{
targetPlayer
.BorrowConsole()
.UseColorOnce(_.color.TextFailure)
.Write(F("There was an internal error with `userdata` command. "))
.Write(P("Please report it!"));
return;
}
targetPlayerName = targetPlayer.GetName();
rawData = identity.GetPersistentData(groupName, dataName);
dataAsJSON = _.json.PrettyPrint(rawData);
targetPlayer.BorrowConsole()
.Write(F("User data for player "))
.Write(targetPlayerName)
.Write(P(": "))
.WriteLine(dataAsJSON);
_.memory.Free(dataAsJSON);
_.memory.Free(rawData);
_.memory.Free(targetPlayerName);
_.memory.Free(identity);
}
private final function WriteUserData(
EPlayer targetPlayer,
BaseText groupName,
BaseText dataName,
AcediaObject rawData)
{
local User identity;
local Text targetPlayerName;
identity = targetPlayer.GetIdentity();
if (identity == none) {
targetPlayer = playerQueue[0];
playerQueue.Remove(0, 1);
if (result != DBR_Success)
{
targetPlayer
.BorrowConsole()
.UseColorOnce(_.color.TextFailure)
.Write(F("There was an error reading user data, error code: "))
.WriteLine(_.text.FromInt(int(result)));
return;
}
targetPlayerName = targetPlayer.GetName();
if (identity.SetPersistentData(groupName, dataName, rawData))
{
asJSON = _.json.PrettyPrint(userData);
targetPlayer.BorrowConsole()
.Write(P("User data for player "))
.Write(F("{$TextPositive User data for player}"))
.Write(targetPlayerName)
.WriteLine(F(" was {$TextPositive successfully} changed!"));
}
else
{
targetPlayer.BorrowConsole()
.Write(P("User data for player "))
.Write(targetPlayerName)
.WriteLine(F(" has {$TextPositive failed} to change!"));
}
.Write(P(":"))
.WriteLine(asJSON);
_.memory.Free(targetPlayer);
_.memory.Free(asJSON);
_.memory.Free(targetPlayerName);
_.memory.Free(identity);
}
defaultproperties {
preferredName = "userdata"
defaultproperties
{
}

80
sources/Features/FutileChat/FutilityChat.uc

@ -1,6 +1,6 @@
/**
* Config class for storing map lists.
* Copyright 2022-2023 Anton Tarasenko
* Config object for `FutilityChat_Feature`.
* Copyright 2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
@ -21,7 +21,8 @@ class FutilityChat extends FeatureConfig
perobjectconfig
config(FutilityChat);
enum ChatColorSetting {
enum ChatColorSetting
{
CCS_DoNothing,
CCS_TeamColorForced,
CCS_ConfigColorForced,
@ -29,45 +30,16 @@ enum ChatColorSetting {
CCS_ConfigColorCustom
};
/// How to color text chat messages?
///
/// 1. `CCS_DoNothing` - do not change color in any way;
/// 2. `CCS_TeamColorForced` - force players' team colors for
/// their messages;
/// 3. `CCS_ConfigColorForced` - force `configuredColor` value for
/// players' messages;
/// 4. `CCS_TeamColorCustom` - use players' team colors for
/// their messages by default, but allow to change color with formatted tags
/// (e.g. "Stop right there, {$crimson criminal} scum!");
/// 5. `CCS_ConfigColorCustom` - use `configuredColor` value for
/// messages by default, but allow to change color with formatted
/// tags (e.g. "Stop right there, {$crimson criminal} scum!");
///
/// Default is `CCS_DoNothing`, corresponding to vanilla behaviour.
var public config ChatColorSetting colorSetting;
/// Color that will be used if either of `CCS_ConfigColorForced` or
/// `CCS_ConfigColorCustom` options were used in `colorSetting`.
/// Default value is white: (R=255,G=255,B=255,A=255), has no vanilla
/// equivalent.
var public config Color configuredColor;
/// Allows to modify team color's value for the chat messages
/// (if either of `CCS_TeamColorForced` or `CCS_TeamColorCustom` options
/// were used) to be lighter or darker.
/// This value is clamped between -1 and 1:
///
/// * `0` means using the same color;
/// * range (0; 1) - gives you lighter colors (`1` being white);
/// * range (-1; 0) - gives you darker colors (`-1` being black);
///
/// Default value is `0.6`, has no vanilla equivalent.
var public config float teamColorModifier;
protected function HashTable ToData() {
protected function HashTable ToData()
{
local HashTable data;
local Text colorAsText;
data = __().collections.EmptyHashTable();
data.SetString(P("colorSetting"), StringFromColorSetting(colorSetting));
data.SetString(P("colorSetting"), string(colorSetting));
colorAsText = _.color.ToText(configuredColor);
data.SetItem(P("configuredColor"), colorAsText);
_.memory.Free(colorAsText);
@ -75,10 +47,12 @@ protected function HashTable ToData() {
return data;
}
protected function FromData(HashTable source) {
protected function FromData(HashTable source)
{
local Text storedText;
if (source != none) {
if (source == none) {
return;
}
storedText = source.GetText(P("colorSetting"));
colorSetting = ColorSettingFromText(storedText);
_.memory.Free(storedText);
@ -86,10 +60,11 @@ protected function FromData(HashTable source) {
_.color.Parse(storedText, configuredColor);
_.memory.Free(storedText);
teamColorModifier = source.GetFloat(P("teamColorModifier"), 0.5);
}
}
private function ChatColorSetting ColorSettingFromText(BaseText permissions) {
private function ChatColorSetting ColorSettingFromText(
BaseText permissions)
{
if (permissions == none) {
return CCS_DoNothing;
}
@ -108,32 +83,15 @@ private function ChatColorSetting ColorSettingFromText(BaseText permissions) {
return CCS_DoNothing;
}
private function string StringFromColorSetting(ChatColorSetting permissions) {
if (permissions == CCS_DoNothing) {
return "DoNothing";
}
if (permissions == CCS_TeamColorForced) {
return "TeamColorForced";
}
if (permissions == CCS_ConfigColorForced) {
return "ConfigColorForced";
}
if (permissions == CCS_TeamColorCustom) {
return "TeamColorCustom";
}
if (permissions == CCS_ConfigColorCustom) {
return "ConfigColorCustom";
}
return "DoNothing";
}
protected function DefaultIt() {
protected function DefaultIt()
{
colorSetting = CCS_DoNothing;
configuredColor = _.color.RGB(255, 255, 255);
teamColorModifier = 0.6;
}
defaultproperties {
defaultproperties
{
configName = "FutilityChat"
colorSetting = CCS_DoNothing
configuredColor = (R=255,G=255,B=255,A=255)

90
sources/Features/FutileChat/FutilityChat_Feature.uc

@ -1,6 +1,6 @@
/**
* Config class for storing map lists.
* Copyright 2022-2023 Anton Tarasenko
* This feature allows to configure color of text chat messages.
* Copyright 2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
@ -20,22 +20,44 @@
class FutilityChat_Feature extends Feature
dependson(FutilityChat);
// How to color text chat messages?
// 1. `CCS_DoNothing` - do not change color in any way;
// 2. `CCS_TeamColorForced` - force players' team colors for
// their messages;
// 3. `CCS_ConfigColorForced` - force `configuredColor` value for
// players' messages;
// 4. `CCS_TeamColorCustom` - use players' team colors for
// their messages by default, but allow to change color with formatted
// tags (e.g. "Stop right there, {$crimson criminal} scum!");
// 5. `CCS_ConfigColorCustom` - use `configuredColor` value for
// messages by default, but allow to change color with formatted
// tags (e.g. "Stop right there, {$crimson criminal} scum!");
// Default is `CCS_DoNothing`, corresponding to vanilla behaviour.
var private /*config*/ FutilityChat.ChatColorSetting colorSetting;
// Color that will be used if either of `CCS_ConfigColorForced` or
// `CCS_ConfigColorCustom` options were used in `colorSetting`.
// Default value is white: (R=255,G=255,B=255,A=255),
// has no vanilla equivalent.
var private /*config*/ Color configuredColor;
// Allows to modify team color's value for the chat messages
// (if either of `CCS_TeamColorForced` or `CCS_TeamColorCustom` options
// were used) to be lighter or darker.
// This value is clamped between -1 and 1.
// * `0` means using the same color;
// * range (0; 1) - gives you lighter colors (`1` being white);
// * range (-1; 0) - gives you darker colors (`-1` being black);
// Default value is `0.6`, has no vanilla equivalent.
var private /*config*/ float teamColorModifier;
/// Keep track of whether we connected to necessary signals, so that we can
/// connect to them or disconnect from them once setting get updated
// Keep track of whether we connected to necessary signals, so that we can
// connect to them or disconnect from them once setting get updated
var private bool connectedToSignal;
protected function OnEnabled() {
if (colorSetting != CCS_DoNothing) {
_.chat.OnMessage(self).connect = ReformatChatMessage;
}
}
protected function OnDisabled() {
if (colorSetting != CCS_DoNothing) {
protected function OnDisabled()
{
if (connectedToSignal)
{
connectedToSignal = false;
_.chat.OnMessage(self).Disconnect();
}
}
@ -44,7 +66,6 @@ protected function SwapConfig(FeatureConfig config)
{
local bool configRequiresSignal;
local FutilityChat newConfig;
newConfig = FutilityChat(config);
if (newConfig == none) {
return;
@ -53,49 +74,69 @@ protected function SwapConfig(FeatureConfig config)
configuredColor = newConfig.configuredColor;
teamColorModifier = newConfig.teamColorModifier;
configRequiresSignal = (colorSetting != CCS_DoNothing);
// Enable or disable censoring if `IsAnyCensoringEnabled()`'s response
// has changed.
if (!connectedToSignal && configRequiresSignal)
{
connectedToSignal = true;
_.chat.OnMessage(self).connect = ReformatChatMessage;
}
if (connectedToSignal && !configRequiresSignal)
{
connectedToSignal = false;
_.chat.OnMessage(self).Disconnect();
}
}
private function bool ReformatChatMessage(
EPlayer sender,
MutableText message,
bool teamMessage
) {
bool teamMessage)
{
local Text messageCopy;
local BaseText.Formatting defaultFormatting;
if (sender == none) return true;
if (message == none) return true;
if (colorSetting == CCS_DoNothing) return true;
defaultFormatting.isColored = true;
if (colorSetting == CCS_TeamColorForced || colorSetting == CCS_TeamColorCustom) {
if ( colorSetting == CCS_TeamColorForced
|| colorSetting == CCS_TeamColorCustom)
{
defaultFormatting.color = ModColor(sender.GetTeamColor());
} else {
}
else {
defaultFormatting.color = configuredColor;
}
if (message.StartsWith(P("|"))) {
message.Remove(0, 1);
} else if (colorSetting != CCS_TeamColorForced && colorSetting != CCS_ConfigColorForced) {
}
else if ( colorSetting != CCS_TeamColorForced
&& colorSetting != CCS_ConfigColorForced)
{
messageCopy = message.Copy();
class'FormattingStringParser'.static.ParseFormatted(messageCopy, message.Clear());
class'FormattingStringParser'.static
.ParseFormatted(messageCopy, message.Clear());
_.memory.Free(messageCopy);
}
message.ChangeDefaultFormatting(defaultFormatting);
return true;
}
private function Color ModColor(Color inputColor) {
private function Color ModColor(Color inputColor)
{
local Color mixColor;
local Color outputColor;
local float clampedModifier;
if (Abs(teamColorModifier) < 0.001) {
return inputColor;
}
clampedModifier = FClamp(teamColorModifier, -1.0, 1.0);
if (clampedModifier > 0) {
mixColor = _.color.White;
} else {
}
else
{
mixColor = _.color.Black;
clampedModifier *= -1.0;
}
@ -106,6 +147,7 @@ private function Color ModColor(Color inputColor) {
return outputColor;
}
defaultproperties {
defaultproperties
{
configClass = class'FutilityChat'
}

114
sources/Features/FutileNickames/FutilityNicknames.uc

@ -1,6 +1,6 @@
/**
* Config class for storing map lists.
* Copyright 2022-2023 Anton Tarasenko
* Config object for `FutileNickames_Feature`.
* Copyright 2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
@ -21,108 +21,62 @@ class FutilityNicknames extends FeatureConfig
perobjectconfig
config(FutilityNicknames);
enum NicknameSpacesAction {
enum NicknameSpacesAction
{
NSA_DoNothing,
NSA_Trim,
NSA_Simplify
};
enum NicknameColorPermissions {
enum NicknameColorPermissions
{
NCP_ForbidColor,
NCP_ForceTeamColor,
NCP_ForceSingleColor,
NCP_AllowAnyColor
};
/// How to treat whitespace characters inside players' nicknames:
///
/// * `NSA_DoNothing` - does nothing, leaving whitespaces as they are;
/// * `NSA_Trim` - removes leading and trailing whitespaces for nicknames;
/// * `NSA_Simplify` - removes leading and trailing whitespaces
/// for nicknames, also reducing a sequence of whitespaces inside
/// nickname to a single space, e.g. "my nick" becomes "my nick".
///
/// Default is `NSA_DoNothing`, same as on vanilla.
var public config NicknameSpacesAction spacesAction;
/// How to treat colored nicknames:
///
/// * `NCP_ForbidColor` - completely strips down any color from nicknames;
/// * `NCP_ForceTeamColor` - forces all nicknames to have player's current
/// team's color;
/// * `NCP_ForceSingleColor` - allows nickname to be painted with a single
/// color (sets nickname's color to that of the first character);
/// * `NCP_AllowAnyColor` - allows nickname to be colored in any way player
/// wants.
/// Default is `NCP_ForbidColor`, same as on vanilla.
var public config NicknameColorPermissions colorPermissions;
/// Set this to `true` if you wish to replace all whitespace characters with
/// underscores and `false` to leave them as is.
/// Default is `true`, same as on vanilla. However there is one difference:
/// Futility replaces all whitespace characters (including tabulations,
/// non-breaking spaces, etc.) instead of only ' '.
var public config bool replaceSpacesWithUnderscores;
/// Set this to `true` to remove single 'quotation marks' and `false` to
/// leave them. Default is `false`, same as on vanilla.
var public config bool removeSingleQuotationMarks;
/// Set this to `true` to remove dobule 'quotation marks' and `false` to
/// leave them. Default is `true`, same as on vanilla.
var public config bool removeDoubleQuotationMarks;
/// Should we replace empty player nicknames with a random fallback nickname
/// (defined in `fallbackNickname` array)?
var public config bool correctEmptyNicknames;
/// Max allowed nickname length. Negative values disable any length limits.
///
/// NOTE #1: `0` resets all nicknames to be empty and,
/// if `correctEmptyNicknames` is set to `true`, they will be replaced with
/// one of the fallback nicknames (see `correctEmptyNicknames` and
/// `fallbackNickname`).
///
/// NOTE #2: Because of how color swapping in vanilla Killing Floor works,
/// every color swap makes text count as being about 4 characters longer.
/// So if one uses too many colors in the nickname, for drawing functions
/// it will appear to be longer than it actually is and it *will* mess up
/// UI. Unless you are using custom HUD it is recommended to keep this value
/// at default `20` and forbid colored nicknames (by setting
/// `colorPermissions=NCP_ForbidColor`). Or to allow only one color (by setting
/// `colorPermissions=NCP_ForceSingleColor` or
/// `colorPermissions=NCP_ForceTeamColor`) and reducing `maxNicknameLength` to
/// `16` (20 characters - 4 for color swap).
/// If you want to increase the limit above that, you can also do your own
/// research by testing nicknames of various length on screen resolutions you
/// care about.
var public config int maxNicknameLength;
/// Array of fallback nicknames that will be used to replace any empty nicknames
/// if `correctEmptyNicknames` is set to `true`.
var public config array<string> fallbackNickname;
protected function HashTable ToData() {
protected function HashTable ToData()
{
local int i;
local ArrayList fallbackNicknamesData;
local HashTable data;
data = __().collections.EmptyHashTable();
data.SetString(P("spacesAction"), string(spacesAction));
data.SetString(P("colorPermissions"), string(colorPermissions));
data.SetBool(P("replaceSpacesWithUnderscores"), replaceSpacesWithUnderscores);
data.SetBool(P("removeSingleQuotationMarks"), removeSingleQuotationMarks);
data.SetBool(P("removeDoubleQuotationMarks"), removeDoubleQuotationMarks);
data.SetBool( P("replaceSpacesWithUnderscores"),
replaceSpacesWithUnderscores);
data.SetBool( P("removeSingleQuotationMarks"),
removeSingleQuotationMarks);
data.SetBool( P("removeDoubleQuotationMarks"),
removeDoubleQuotationMarks);
data.SetBool(P("correctEmptyNicknames"), correctEmptyNicknames);
data.SetInt(P("maxNicknameLength"), maxNicknameLength);
fallbackNicknamesData = __().collections.EmptyArrayList();
for (i = 0; i < fallbackNickname.length; i += 1) {
fallbackNicknamesData.AddItem(__().text.FromFormattedString(fallbackNickname[i]));
for (i = 0; i < fallbackNickname.length; i += 1)
{
fallbackNicknamesData.AddItem(
__().text.FromFormattedString(fallbackNickname[i]));
}
data.SetItem(P("fallbackNickname"), fallbackNicknamesData);
_.memory.Free(fallbackNicknamesData);
return data;
}
protected function FromData(HashTable source) {
protected function FromData(HashTable source)
{
local int i;
local Text nextNickName, storedText;
local ArrayList fallbackNicknamesData;
if (source == none) {
return;
}
@ -132,20 +86,25 @@ protected function FromData(HashTable source) {
storedText = source.GetText(P("colorPermissions"));
colorPermissions = ColorPermissionsFromText(storedText);
_.memory.Free(storedText);
replaceSpacesWithUnderscores = source.GetBool(P("replaceSpacesWithUnderscores"), true);
removeSingleQuotationMarks = source.GetBool(P("removeSingleQuotationMarks"), true);
removeDoubleQuotationMarks = source.GetBool(P("removeDoubleQuotationMarks"), true);
replaceSpacesWithUnderscores =
source.GetBool(P("replaceSpacesWithUnderscores"), true);
removeSingleQuotationMarks =
source.GetBool(P("removeSingleQuotationMarks"), true);
removeDoubleQuotationMarks =
source.GetBool(P("removeDoubleQuotationMarks"), true);
correctEmptyNicknames = source.GetBool(P("correctEmptyNicknames"), true);
maxNicknameLength = source.GetInt(P("correctEmptyNicknames"), 20);
fallbackNicknamesData = source.GetArrayList(P("fallbackNickname"));
if (fallbackNickname.length > 0) {
fallbackNickname.length = 0;
}
for (i = 0; i < fallbackNicknamesData.GetLength(); i += 1) {
for (i = 0; i < fallbackNicknamesData.GetLength(); i += 1)
{
nextNickName = fallbackNicknamesData.GetText(i);
if (nextNickName != none) {
fallbackNickname[i] = nextNickName.ToFormattedString();
} else {
}
else {
fallbackNickname[i] = "";
}
_.memory.Free(nextNickName);
@ -153,7 +112,8 @@ protected function FromData(HashTable source) {
_.memory.Free(fallbackNicknamesData);
}
private function NicknameSpacesAction SpaceActionFromText(BaseText action) {
private function NicknameSpacesAction SpaceActionFromText(BaseText action)
{
if (action == none) {
return NSA_DoNothing;
}
@ -169,7 +129,9 @@ private function NicknameSpacesAction SpaceActionFromText(BaseText action) {
return NSA_DoNothing;
}
private function NicknameColorPermissions ColorPermissionsFromText(BaseText permissions) {
private function NicknameColorPermissions ColorPermissionsFromText(
BaseText permissions)
{
if (permissions == none) {
return NCP_ForbidColor;
}
@ -188,7 +150,8 @@ private function NicknameColorPermissions ColorPermissionsFromText(BaseText perm
return NCP_ForbidColor;
}
protected function DefaultIt() {
protected function DefaultIt()
{
spacesAction = NSA_DoNothing;
colorPermissions = NCP_ForbidColor;
replaceSpacesWithUnderscores = true;
@ -211,7 +174,8 @@ protected function DefaultIt() {
fallbackNickname[9] = "Bug Meat";
}
defaultproperties {
defaultproperties
{
configName = "FutilityNicknames"
spacesAction = NSA_DoNothing
colorPermissions = NCP_ForbidColor

288
sources/Features/FutileNickames/FutilityNicknames_Feature.uc

@ -1,6 +1,9 @@
/**
* Config class for storing map lists.
* Copyright 2022-2023 Anton Tarasenko
* This feature allows to configure nickname limitations for the server.
* It allows you to customize vanilla limitations for nickname length and
* color with those of your own design. Enabling this feature overwrites
* default behaviour.
* Copyright 2022 Anton Tarasenko
*------------------------------------------------------------------------------
* This file is part of Acedia.
*
@ -20,88 +23,155 @@
class FutilityNicknames_Feature extends Feature
dependson(FutilityNicknames);
//! This feature's functionality is rather simple, but we will still break up
//! what its various components are.
//!
//! Fallback nicknames are picked at random from
//! the `fallbackNicknames` array. This is done by copying that array into
//! `unusedNicknames` and then picking and removing its random elements each
//! time we need a fallback. Once `unusedNicknames` is empty - it is copied from
//! `fallbackNicknames` once again, letting already used nicknames to be reused.
//! `unusedNicknames` contains same references as `fallbackNicknames`,
//! so they need to be separately deallocated and should also be forgotten once
//! `fallbackNicknames` are deallocated`.
//! This is implemented inside `PickNextFallback()` method.
//!
//! Nickname changes are applied inside `CensorNickname()` method that uses
//! several auxiliary methods to perform different stages of "censoring".
//! Censoring is performed:
//! 1. On any player's name change
//! (using `OnPlayerNameChanging()` signal, connected to
//! `HandleNicknameChange()`);
//! 2. When new player logins (using `OnNewPlayer()` signal,
//! conneted to `CensorOriginalNickname()`) to enforce our own
//! handling of player's original nickname.
/**
* This feature's functionality is rather simple, but we will still break up
* what its various components are.
*
* Fallback nicknames are picked at random from
* the `fallbackNicknames` array. This is done by copying that array into
* `unusedNicknames` and then picking and removing its random elements each
* time we need a fallback. Once `unusedNicknames` is empty - it is copied from
* `fallbackNicknames` once again, letting already used nicknames to be reused.
* `unusedNicknames` contains same references as `fallbackNicknames`,
* so they need to be separately deallocated and should also be forgotten once
* `fallbackNicknames` are deallocated`.
* This is implemented inside `PickNextFallback()` method.
*
* Nickname changes are applied inside `CensorNickname()` method that uses
* several auxiliary methods to perform different stages of "censoring".
* Censoring is performed:
* 1. On any player's name change
* (using `OnPlayerNameChanging()` signal, connected to
* `HandleNicknameChange()`);
* 2. When new player logins (using `OnNewPlayer()` signal,
* conneted to `CensorOriginalNickname()`) to enforce our own
* handling of player's original nickname;
* 3. When censoring is re-activated.
* In case all censoring options of this feature are disabled
* (checked by `IsAnyCensoringEnabled()`) - we do not attempt to
* catch any events or do anything at all.
* If settings change mid-execution, this feature might need to
* enable or disable censoring on-the-fly. To accomplish that we
* remember current status inside `censoringNicknames` boolean
* variable and enable/disable events if required by settings.
* So whenever we re-activate censoring we also need to update
* ("censor") current players' nicknames - a third occasion to
* call `CensorNickname()`, implemented inside
* `CensorCurrentPlayersNicknames()`.
*/
// How to treat whitespace characters inside players' nicknames.
// * `NSA_DoNothing` - does nothing, leaving whitespaces as they are;
// * `NSA_Trim` - removes leading and trailing whitespaces for nicknames;
// * `NSA_Simplify` - removes leading and trailing whitespaces
// for nicknames, also reducing a sequence of whitespaces inside
// nickname to a single space, e.g. "my nick" becomes "my nick".
// Default is `NSA_DoNothing`, same as on vanilla.
var private /*config*/ FutilityNicknames.NicknameSpacesAction spacesAction;
// How to treat colored nicknames.
// * `NCP_ForbidColor` - completely strips down any color from nicknames;
// * `NCP_ForceTeamColor` - forces all nicknames to have player's current
// team's color;
// * `NCP_ForceSingleColor` - allows nickname to be painted with a single
// color (sets nickname's color to that of the first character);
// * `NCP_AllowAnyColor` - allows nickname to be colored in any way player
// wants.
// Default is `NCP_ForbidColor`, same as on vanilla.
var private /*config*/ FutilityNicknames.NicknameColorPermissions colorPermissions;
// Set this to `true` if you wish to replace all whitespace characters with
// underscores and `false` to leave them as is.
// Default is `true`, same as on vanilla. However there is one difference:
// Futility replaces all whitespace characters (including tabulations,
// non-breaking spaces, etc.) instead of only ' '.
var private /*config*/ bool replaceSpacesWithUnderscores;
// Set this to `true` to remove single 'quotation marks' and `false` to
// leave them. Default is `false`, same as on vanilla.
var private /*config*/ bool removeSingleQuotationMarks;
// Set this to `true` to remove dobule 'quotation marks' and `false` to
// leave them. Default is `true`, same as on vanilla.
var private /*config*/ bool removeDoubleQuotationMarks;
// Max allowed nickname length. Negative values disable any length limits.
//
// NOTE #1: `0` resets all nicknames to be empty and,
// if `correctEmptyNicknames` is set to `true`, they will be replaced with
// one of the fallback nicknames
// (see `correctEmptyNicknames` and `fallbackNickname`).
// NOTE #2: Because of how color swapping in vanilla Killing Floor works,
// every color swap makes text count as being about 4 characters longer.
// So if one uses too many colors in the nickname, for drawing functions
// it will appear to be longer than it actually is and it *will* mess up
// UI. Unless you are using custom HUD it is recommended to keep this value
// at default `20` and forbid colored nicknames
// (by setting `colorPermissions=NCP_ForbidColor`). Or to allow only one
// color (by setting `colorPermissions=NCP_ForceSingleColor` or
// `colorPermissions=NCP_ForceTeamColor`) and reducing `maxNicknameLength`
// to `16` (20 characters - 4 for color swap).
// If you want to increase the limit above that, you can also do your
// own research by testing nicknames of various length on
// screen resolutions you care about.
var private /*config*/ int maxNicknameLength;
// Should we replace empty player nicknames with a random fallback nickname
// (defined in `fallbackNickname` array)?
var private /*config*/ bool correctEmptyNicknames;
// Array of fallback nicknames that will be used to replace any empty nicknames
// if `correctEmptyNicknames` is set to `true`.
var private /*config*/ array<Text> fallbackNickname;
/// Guaranteed order of applying changes (only chosen ones) is as following:
///
/// 1. Trim/simplify spaces;
/// 2. Remove single and double quotation marks;
/// 3. Enforce max limit of nickname's length;
/// 4. Replace empty nickname with fallback nickname (no further changes
/// will be applied to fallback nickname in that case);
/// 5. Enforce color limitation;
/// 6. Replace remaining whitespaces with underscores.
///
/// NOTE #1: as follows from the instruction described above, no changes will
/// ever be applied to fallback nicknames (unless player's nickname coincides
/// with one by pure accident).
///
/// NOTE #2: whitespaces inside steam nicknames are converted into underscores
/// before they are passed into the game and this is a change Futility
/// cannot currently abort. Therefore all changes relevant to whitespaces inside
/// nicknames will only be applied to in-game changes.
// Guaranteed order of applying changes (only chosen ones) is as following:
// 1. Trim/simplify spaces;
// 2. Remove single and double quotation marks;
// 3. Enforce max limit of nickname's length;
// 4. Replace empty nickname with fallback nickname (no further changes
// will be applied to fallback nickname in that case);
// 5. Enforce color limitation;
// 6. Replace remaining whitespaces with underscores.
//
// NOTE #1: as follows from the instruction described above, no changes will
// ever be applied to fallback nicknames (unless player's nickname
// coincides with one by pure accident).
// NOTE #2: whitespaces inside steam nicknames are converted into underscores
// before they are passed into the game and this is a change Futility
// cannot currently abort.
// Therefore all changes relevant to whitespaces inside nicknames will only
// be applied to in-game changes.
/// Nicknames from `fallbackNickname` that can still be picked in the current
/// rotation.
// Nicknames from `fallbackNickname` that can still be picked in
// the current rotation.
var private array<Text> unusedNicknames;
// Are we currently censoring nicknames?
// Set to `false` if none of the feature's options require
// any action (censoring) and, therefore, we do not listen to any signals.
var private bool censoringNicknames;
var private const int CODEPOINT_UNDERSCORE;
protected function OnEnabled() {
if (IsAnyCensoringEnabled()) {
// Do this before adding event handler to avoid censoring nicknames
// second time (censoring nickname will trigger `OnPlayerNameChanging()`
// signal)
CensorCurrentPlayersNicknames();
_.players.OnPlayerNameChanging(self).connect = HandleNicknameChange;
_.players.OnNewPlayer(self).connect = CensorOriginalNickname;
}
}
protected function OnDisabled() {
protected function OnDisabled()
{
_.memory.FreeMany(fallbackNickname);
// Free this `Text` data - it will be refilled with `SwapConfig()`
// if this feature is ever reenabled
if (fallbackNickname.length > 0)
{
_.memory.FreeMany(fallbackNickname);
_.memory.FreeMany(unusedNicknames);
fallbackNickname.length = 0;
unusedNicknames.length = 0;
if (IsAnyCensoringEnabled()) {
}
if (censoringNicknames)
{
censoringNicknames = false;
_.players.OnPlayerNameChanging(self).Disconnect();
_.players.OnNewPlayer(self).Disconnect();
}
}
protected function SwapConfig(FeatureConfig config) {
protected function SwapConfig(FeatureConfig config)
{
local bool configRequiresCensoring;
local FutilityNicknames newConfig;
newConfig = FutilityNicknames(config);
if (newConfig == none) {
return;
@ -113,25 +183,33 @@ protected function SwapConfig(FeatureConfig config) {
spacesAction = newConfig.spacesAction;
colorPermissions = newConfig.colorPermissions;
maxNicknameLength = newConfig.maxNicknameLength;
SwapFallbackNicknames(newConfig);
}
private function SwapFallbackNicknames(FutilityNicknames newConfig) {
local int i;
_.memory.FreeMany(fallbackNickname);
fallbackNickname.length = 0;
for (i = 0; i < newConfig.fallbackNickname.length; i += 1) {
fallbackNickname[i] = _.text.FromFormattedString(newConfig.fallbackNickname[i]);
configRequiresCensoring = IsAnyCensoringEnabled();
// Enable or disable censoring if `IsAnyCensoringEnabled()`'s response
// has changed.
if (!censoringNicknames && configRequiresCensoring)
{
censoringNicknames = true;
// Do this before adding event handler to
// avoid censoring nicknames second time
CensorCurrentPlayersNicknames();
_.players.OnPlayerNameChanging(self).connect = HandleNicknameChange;
_.players.OnNewPlayer(self).connect = CensorOriginalNickname;
}
unusedNicknames = fallbackNickname;
if (censoringNicknames && !configRequiresCensoring)
{
censoringNicknames = false;
_.players.OnPlayerNameChanging(self).Disconnect();
_.players.OnNewPlayer(self).Disconnect();
}
SwapFallbackNicknames(newConfig);
}
private function Text PickNextFallback() {
private function Text PickNextFallback()
{
local int pickedIndex;
local Text result;
if (fallbackNickname.length <= 0) {
if (fallbackNickname.length <= 0)
{
// Just in case this feature is really misconfigured
return P("Fresh Meat").Copy();
}
@ -146,7 +224,23 @@ private function Text PickNextFallback() {
return result;
}
private function bool IsAnyCensoringEnabled() {
protected function SwapFallbackNicknames(FutilityNicknames newConfig)
{
local int i;
_.memory.FreeMany(fallbackNickname);
if (fallbackNickname.length > 0) {
fallbackNickname.length = 0;
}
for (i = 0; i < newConfig.fallbackNickname.length; i += 1)
{
fallbackNickname[i] =
_.text.FromFormattedString(newConfig.fallbackNickname[i]);
}
unusedNicknames = fallbackNickname;
}
private function bool IsAnyCensoringEnabled()
{
return ( replaceSpacesWithUnderscores
|| removeSingleQuotationMarks
|| removeDoubleQuotationMarks
@ -160,13 +254,14 @@ private function bool IsAnyCensoringEnabled() {
private function HandleNicknameChange(
EPlayer affectedPlayer,
BaseText oldName,
MutableText newName
) {
MutableText newName)
{
CensorNickname(newName, affectedPlayer);
}
// For handling of player's original nicknames.
private function CensorOriginalNickname(EPlayer affectedPlayer) {
private function CensorOriginalNickname(EPlayer affectedPlayer)
{
local Text originalNickname;
if (affectedPlayer == none) {
return;
@ -180,14 +275,15 @@ private function CensorOriginalNickname(EPlayer affectedPlayer) {
// For handling nicknames of players after censoring is re-activated by
// config change.
private function CensorCurrentPlayersNicknames() {
private function CensorCurrentPlayersNicknames()
{
local int i;
local Text nextNickname;
local MutableText alteredNickname;
local array<EPlayer> currentPlayers;
currentPlayers = _.players.GetAll();
for (i = 0; i < currentPlayers.length; i += 1) {
for (i = 0; i < currentPlayers.length; i += 1)
{
nextNickname = currentPlayers[i].GetName();
alteredNickname = nextNickname.MutableCopy();
CensorNickname(alteredNickname, currentPlayers[i]);
@ -199,10 +295,10 @@ private function CensorCurrentPlayersNicknames() {
}
}
private function CensorNickname(MutableText nickname, EPlayer affectedPlayer) {
private function CensorNickname(MutableText nickname, EPlayer affectedPlayer)
{
local Text fallback;
local BaseText.Formatting newFormatting;
if (nickname == none) return;
if (affectedPlayer == none) return;
@ -218,16 +314,20 @@ private function CensorNickname(MutableText nickname, EPlayer affectedPlayer) {
if (maxNicknameLength >= 0) {
nickname.Remove(maxNicknameLength);
}
if (correctEmptyNicknames && nickname.IsEmpty()) {
if (correctEmptyNicknames && nickname.IsEmpty())
{
fallback = PickNextFallback();
nickname.Append(fallback);
_.memory.Free(fallback);
return;
}
if (colorPermissions != NCP_AllowAnyColor) {
if (colorPermissions != NCP_AllowAnyColor)
{
if (colorPermissions == NCP_ForceSingleColor) {
newFormatting = nickname.GetCharacter(0).formatting;
} else if (colorPermissions == NCP_ForceTeamColor) {
}
else if (colorPermissions == NCP_ForceTeamColor)
{
newFormatting.isColored = true;
newFormatting.color = affectedPlayer.GetTeamColor();
}
@ -241,17 +341,20 @@ private function CensorNickname(MutableText nickname, EPlayer affectedPlayer) {
}
// Asusmes `nickname != none`.
private function ReplaceSpaces(MutableText nickname) {
private function ReplaceSpaces(MutableText nickname)
{
local int i;
local MutableText nicknameCopy;
local BaseText.Character nextCharacter, underscoreCharacter;
nicknameCopy = nickname.MutableCopy();
nickname.Clear();
underscoreCharacter = _.text.CharacterFromCodePoint(CODEPOINT_UNDERSCORE);
for (i = 0; i < nicknameCopy.GetLength(); i += 1) {
underscoreCharacter =
_.text.CharacterFromCodePoint(CODEPOINT_UNDERSCORE);
for (i = 0; i < nicknameCopy.GetLength(); i += 1)
{
nextCharacter = nicknameCopy.GetCharacter(i);
if (_.text.IsWhitespace(nextCharacter)) {
if (_.text.IsWhitespace(nextCharacter))
{
// Replace character with underscore, leaving the formatting
underscoreCharacter.formatting = nextCharacter.formatting;
nextCharacter = underscoreCharacter;
@ -261,7 +364,8 @@ private function ReplaceSpaces(MutableText nickname) {
_.memory.Free(nicknameCopy);
}
defaultproperties {
defaultproperties
{
configClass = class'FutilityNicknames'
CODEPOINT_UNDERSCORE = 95 // '_'
}

12
sources/Futility.uc

@ -21,16 +21,20 @@ class Futility extends FeatureConfig
perobjectconfig
config(Futility);
protected function HashTable ToData() {
protected function HashTable ToData()
{
return _.collections.EmptyHashTable();
}
protected function FromData(HashTable source) {
protected function FromData(HashTable source)
{
}
protected function DefaultIt() {
protected function DefaultIt()
{
}
defaultproperties {
defaultproperties
{
configName = "Futility"
}

6
sources/Futility_Feature.uc

@ -36,7 +36,7 @@ protected function OnEnabled()
return;
}
for (i = 0; i < allCommandClasses.length; i += 1) {
//commandsFeature.RegisterCommand(allCommandClasses[i]);
commandsFeature.RegisterCommand(allCommandClasses[i]);
}
_.environment.OnFeatureEnabled(self).connect = RegisterAllCommandClasses;
}
@ -52,7 +52,7 @@ protected function OnDisabled()
return;
}
for (i = 0; i < allCommandClasses.length; i += 1) {
//ommandsFeature.RegisterCommand(allCommandClasses[i]);
commandsFeature.RegisterCommand(allCommandClasses[i]);
}
}
@ -65,7 +65,7 @@ private final function RegisterAllCommandClasses(Feature enabledFeature)
return;
}
for (i = 0; i < allCommandClasses.length; i += 1) {
//commandsFeature.RegisterCommand(allCommandClasses[i]);
commandsFeature.RegisterCommand(allCommandClasses[i]);
}
}

26
sources/Tools/PendingConfigsTool.uc

@ -186,10 +186,12 @@ public function HashTable GetPendingConfigData(optional bool createIfMissing)
*/
public function PendingConfigToolResult EditConfig(
BaseText pathToValue,
AcediaObject newValue)
BaseText newValue)
{
local HashTable pendingData;
local MutableJsonPointer pointer;
local JSONPointer pointer;
local Parser parser;
local AcediaObject newValueAsJSON;
local PendingConfigToolResult result;
if (pathToValue == none) {
@ -199,17 +201,26 @@ public function PendingConfigToolResult EditConfig(
if (pendingData == none) {
return PCTE_ConfigMissing;
}
// Get guaranteed not-`none` JSON value, treating it as JSON string
// if necessary
parser = _.text.Parse(newValue);
newValueAsJSON = _.json.ParseWith(parser);
parser.FreeSelf();
if (newValueAsJSON == none && newValue != none) {
newValueAsJSON = newValue.Copy();
}
// Set new data
pointer = _.json.MutablePointer(pathToValue);
result = SetItemByJSON(pendingData, pointer, newValue);
pointer = _.json.Pointer(pathToValue);
result = SetItemByJSON(pendingData, pointer, newValueAsJSON);
pointer.FreeSelf();
pendingData.FreeSelf();
_.memory.Free(newValueAsJSON);
return result;
}
private function PendingConfigToolResult SetItemByJSON(
HashTable data,
MutableJsonPointer pointer,
JSONPointer pointer,
AcediaObject jsonValue)
{
local Text containerIndex;
@ -240,10 +251,7 @@ private function PendingConfigToolResult SetItemByJSON(
container.FreeSelf();
return result;
}
/*EditFeatureConfig #1: true
SetItemByJSON: true
SetContainerItemByText: true
EditFeatureConfig #2: true */
private function PendingConfigToolResult SetContainerItemByText(
AcediaObject container,
BaseText containerIndex,

Loading…
Cancel
Save