Browse Source

Prevent circle definitions in atcommands.yml (#9019)

The map-server will now produce an error, if you try to define a circle definition and not silently override internal command definitions.
This may have happened to a certain developer, while testing ban/unban and this is how he noticed.
Lemongrass3110 3 months ago
parent
commit
17f0447b21
1 changed files with 7 additions and 0 deletions
  1. 7 0
      src/map/atcommand.cpp

+ 7 - 0
src/map/atcommand.cpp

@@ -163,6 +163,13 @@ uint64 AtcommandAliasDatabase::parseBodyNode( const ryml::NodeRef& node ){
 			std::string alias;
 			subNode >> alias;
 
+			AtCommandInfo* parent_cmd = get_atcommandinfo_byname( alias.c_str() );
+
+			if( parent_cmd != nullptr ){
+				this->invalidWarning( subNode, "\"%s\" cannot be used as alias for \"%s\", since a command with this name exists.\n", alias.c_str(), command.c_str() );
+				return 0;
+			}
+
 			info->aliases.insert( alias );
 			this->aliases[alias] = command;
 		}