caxanga334/tf-bewithrobots-redux

Changing Config Files Carry Old Attributes

Closed this issue · 3 comments

Help us help you

  • I have checked that my issue doesn't exist yet.
  • I have tried my absolute best to reduce the problem-space and have provided the absolute smallest test-case possible.
  • I can always reproduce the issue with the provided description below.
  • I have checked that my issue still occours when using the plugin's default settings.
  • I am running the original plugin without third-party modifications.

Environment

  • SourceMod version: 1.11
  • Plugin version: 1.2.17
  • I have updated the plugin to the latest version available in the repository and my issue still happens.

Description

Changing the console variable for config files should reload all the new templates. However, omitting the "robotattributes" keyvalue from a template will cause it to carry over the attribute from a previous template that occupied the same template index. Not sure if this is intentional, but can probably be avoided by making it blank like so in the file: "robotattributes" ""

For example, if the template that occupied index 5 had nobomb, the new template at index 5 will carry over the attribute if the line "robotattributes" was omitted.

The cause may be due to this line. Perhaps a default value with a blank string should be set here.

The same probably happens with "description" as well, but I have not checked.

Steps to reproduce

Make a template with the same number in a new file without using "robotattributes", and changing the ConVar to the new file.

Default

		"5"
		{
			"name" "Awper Sniper"
			"robotattributes" "nobomb,alwayscrits"
			"currency" "0"
			"primaryweapon"
			{
				"classname" "tf_weapon_sniperrifle"
				"index" "851"
				"attributes"
				{
					"damage bonus" "1.40"
					"crit kill will gib" "1.0"
				}
			}
			"secondaryweapon"
			{
				"classname" "tf_wearable_razorback"
				"index" "57"
				"spawnchance" "60"
			}
			"meleeweapon"
			{
				"classname" "tf_weapon_club"
				"index" "3"
			}
		}

New

		"5"
		{
			"name" "Adept Archer"
			"health" "1200"
			"scale" "1.3"
			"playerattributes"
			{
				"move speed bonus" "0.85"
				"dmg taken from fire increased" "2"
			}
			"primaryweapon"
			{
				"classname" "tf_weapon_compound_bow"
				"index" "56"
				"attributes"
				{
					"fire rate bonus" "0.6"
					"damage bonus" "0.75"
				}
			}
			"meleeweapon"
			{
				"classname" "tf_weapon_club"
				"index" "3"
			}
		}

There is no "robotattributes" in the new file, but it still carried over the old attributes from the previous.

The cause may be due to this line. Perhaps a default value with a blank string should be set here.

When an optional parameter is omitted, it uses the default value from the function declaration. kvGetString default value for it's last parameter is a blank string. It should be getting blank when omitted already however I don't know how this native is handled on the C++ side.

My mistake, I think that function is working correctly. The problem I believe is because it is blank and therefore g_BNBitsAttribs[][] is not getting overridden when reparsing in RT_PostLoad due to checking the length of the string. https://github.com/caxanga334/tf-bewithrobots-redux/blob/master/addons/sourcemod/scripting/bwrredux/bot_variants.sp#L1054

Fix deployed and confirmed working on my test server. Please test and report.
You can download the fixed plugin binary here.